Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add $fillable & $casts to Models #204

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sfinktah
Copy link

I am not worthy, and this is not quality code,

However I despise having to manually add the $fillable and $casts properties into my Models, when I have this lovely tool that already knows all my column names.

So this:

artisan make:migration:schema create_test2_table \
    --schema="product_id:integer,tag:string,vcdb_group_id:timestamp" \
    --model=Test2

Will now generate this:

// ...
class Test2 extends Model
{
    use HasFactory;

    protected $fillable = ['product_id', 'tag', 'vcdb_group_id'];

    protected $casts = [
        'vcdb_group_id' => 'datetime',
    ];
}

I have an automated Nova::Resource generator too, but I'll look to see how this is received and if there are suggestion for more eloquent code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant