#How to add attributes to model? (Can't find in documentation)

15 messages · Page 1 of 1 (latest)

marsh mason
vital beacon
marsh mason
vital beacon
#

So if you have a column named foo_bar in the database table, you will be able to access the value of that column via $model->foo_bar

marsh mason
#

ah, so you generate the database tables first

#

then you just tell Larvel to use the schema?

#

I'm use to having to define it in the model Class then run some sort of migrations to create the db/table as needed

vital beacon
#

Yeah, migrations are separated from Eloquent models.

#

So you’d create your tables via migrations.

#

You can generate both the migration file and the Eloquent model class with php artisan make:model Foo -m

#

The -m option will create the migration file. There are other options too for creating things like a factory, a seeder, etc.

marsh mason
#

one as a string and one as a date?

torn sand