Laravel Generate Migration from existing Model
For the model, just create a model, there isn't anything special, just make sure to set the $table
if not following convention.
For generating migrations from an existing Database schema there is a package:
Xethron - Laravel Migration Generator
To create a table for a existing Model, you just have to run below command,
php artisan make:migration table_name
and, go to the database -> migration -> date_with-table_name
inside up()
, type your table name and fields that you want to add, something like belowa;
Schema::create('table_name', function (Blueprint $table) {
$table->increments('id');
$table->string('field_2');
$table->string('field_3');
$table->string('field_4');
$table->date('field_5');
$table->string('field_6');
$table->timestamps();
});
read more here.