Open phpguru opened 6 years ago
The only other thing I do is I remove created_at
, updated_at
and deleted_at
from every $fillable = [ ... ]
array the generator creates. I believe it is desirable to not actually have these be fillable, since Laravel takes care of it automatically when public $timestamps = true;
and use softDeletes;
are present. I think it's arguably fine to leave this in, though, since those fields could be "your schema" and not actually a part of softDeletes & $timestamps.
@phpguru how is it possible to generate the model with this lib? I thought it only generated migration files
@cacpmw I said “model” I meant migration. My comment was pertaining to the fact that when you create a migration with Laravel’s built-in command and put timestamps and soft deletes in the migration, the migration generator should detect this and add the appropriate Laravel specific traits, instead of creating columns. It might do this already, now, it’s been a year. Also for what it’s worth, I use this lib in conjunction with krlove:generate:model, to Laravelize older projects.
This library has saved so much time. The only way this helpful library could be better, IMO, is if you detect
created_at
,updated_at
you includepublic $timestamps = true;
in the generated model, and similarly, if you detectdeleted_at
you injectuse softDeletes
into the class. If there's a config or CLI flag to achieve this optionally, even better. I'd use it. Just filing this here. I can probably craft a PR for it.