This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

dtaub
dtaub

I have some Eloquent models from a private library that are used on other Laravel (not OctoberCMS) projects, and so I can't have them extend the OctoberCMS Model class. This worked great while building out the frontend, but now I'm trying to build a plugin that lists records from these plain Eloquent models, and I discovered that they have to extend the October\Rain\Database\Model class. Is there any way to use plain Eloquent models for lists, without having them extend October's Model class?

Last updated

dtaub
dtaub

So, as I've figured out the answer is no, since it just relies too much on October features to work with plain Eloquent models. This is the workaround I'm using to conditionally extend October models in case anyone else is wondering:

if (class_exists('\October\Rain\Database\Model')) {
    class _BaseModel extends \October\Rain\Database\Model {}
} else {
    class _BaseModel extends \Illuminate\Database\Eloquent\Model {}
}

abstract class BaseModel extends _BaseModel
{
    ...
}

Last updated

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.