Fillable on parent and child
hexatex opened this issue · comments
Cory Baumer commented
I would like to create a set of polymorphic models Dynamic and Regular. They will inherit the same base table "categories". I want to use $dynamic->fill() to fill the attributes of both the parent and child model. Is this possible?
Category
class Category extends Model
{
use Filtered, HasChildren;
/**
* @var array
*/
protected $childTypes = [
'dynamic' => Dynamic::class,
'link' => Link::class,
'regular' => Regular::class,
];
/**
* @var array
*/
protected $fillable = [
'type',
'name',
];
Dynamic
class Dynamic extends Model implements CategoryType, Criteriable
{
use HasParent;
/**
* @var string
*/
protected $table = 'category_dynamics';
/**
* @var array
*/
protected $fillable = [
'lol',
];
$fill = [
'name' => "Laughing Acronyms"
'lol' => 'rofl',
];
$dynamic = new Dynamic($fill);
$dynamic->save();
It' be cooler if it did
Cory Baumer commented
I was confusing this package with one that allowed for multi table inheritance. I will come back to this project if I can't find a multi table solution.