create model, migration and controller
php artisan make:model Task -crm
configure migration file
$table->bigIncrements('id');
$table->string('name');
$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users');
$table->timestamps();
move task migration file temporary into another folder
mv database/migrations/2019_10_01_173218_create_tasks_table.php database/migrations/selected/
migrate all others migrations
php artisan migrate
migrate tasks
php artisan migrate --path=/database/migrations/selected/
define Task relationship in model User
/**
* Get all of the tasks for the user.
*/
public function tasks(){
return $this->hasMany('App\Task');
}
define User relationship in model Task
/**
* Get the user that owns the task.
*/
public function user()
{
return $this->belongsTo('App\User');
}