php artisan make:model Task -m -f
// task is not completed by default
$table->boolean('completed')->default(false);
// connect with project_id i.e. primary key
$table->unsignedInteger('project_id');
In Project, Project has many Tasks
public function tasks() {
return $this->hasMany(Task::class);
}
@if($project->tasks->count())
<div>
@foreach ($project->$tasks as $task)
<li>{{ $task->description }}</li>
@endforeach
@endif
In Task model:
public function project() {
return $this->belongsTo(Project::class);
}