Answer the question
In order to leave comments, you need to log in
How to connect correctly 2 models in this case?
There is a Task model. The structure in the database is:
tasks
id
user_id
task_type_id
data
task_types
id
service_id
name
Answer the question
In order to leave comments, you need to log in
Something like this
class TaskType extends Model
{
public function tasks()
{
return $this->hasMany('App\Models\Task');
}
}
class Task extends Model
{
public function type() {
return $this->belongsTo('App\Models\TaskType');
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question