JREAM
JREAM

Reputation: 5931

Laravel Models Defining Columns Possible?

I just started playing with Laravel, and was wondering the following:

Can you define your table structure in the model, then create a migration based off it? (The way Django works).

 namespace App;

 use Illuminate\Database\Eloquent\Model;


 class SomeListing extends Model
 {
     // Below V V V V Define Columns

     public $title = ''; // somehow make a string(255)?
     public $description = ''; // somehow make a text?

     // etc
     // etc
 }

Or must you always adjust the migration files? I could not find this here.

Upvotes: 1

Views: 2359

Answers (1)

Esteban Bautista
Esteban Bautista

Reputation: 96

I think it does not exist, but you can create migrations for your database with migrations

Create migration

php artisan make:migration create_table_name

and

php artisan migrate

More info could be found at Laravel's Migration Document

Upvotes: 2

Related Questions