Allow models to be extended #39207
-
Recently I was working on a project where we had to use subclasses for a specific model, but we had to store them in the same database. By using subclasses, we are able to implement some different business logic in each subclass, while keeping the ability to query all records at the same time using, for example, This allows the following structure: class Movie extends \Illuminate\Database\Eloquent\Model
{
// Parent properties and methods
}
class Thriller extends Movie
{
// Sub model specific properties and methods
}
class Comedy extends Movie
{
// Sub model specific properties and methods
} Would this be something for the framework core? We have a working implementation, so I could extract the code and make a PR. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
There is a great package for exactly that: https://github.com/calebporzio/parental |
Beta Was this translation helpful? Give feedback.
There is a great package for exactly that: https://github.com/calebporzio/parental