Open phiter opened 6 years ago
Thanks. I have added to 1.0.0+
milestone, but it doesn't mean that will be a very future feature. Is just a control milestone.
It should works like:
$fillable = [
'name',
'age'
];
App\User::create([
'name' => 'John',
'age' => 18,
'title' => 'Commander',
// Warn: property $title was not declared as $fillable.
// Quick-fix: add $title to $fillable array.
]);
I'd add this too if possible/necessary:
/* @property int $age */
$fillable = [
'name',
'age'
];
App\User::create([
'name' => 'John',
'age' => "18", // Warning: expected type is integer, string given.
]);
Uhh... I don't know if it is possible, but I can try. Could you please create another issue for that? Just fill title and put a reference to your previous comment.
The
$fillable
array defines what columns in a model can be filled trough mass assignment.It'd allow us to use this function:
$flight = App\Flight::create(['name' => 'Flight 10']);
Or this one if the model is already defined:
$flight->fill(['name' => 'Flight 22']);
Could you add inspection for this array, and maybe typehint the expected type on the
fill
andcreate
methods based on annotated column type?Thanks!