Relations help Laravel
I have a problem with relations and can’t solve that.
I have 3 models:
1st CarRepair
This has function:
public function parts_list()
{
return $this->hasMany('AppRepairPart', 'repair_id')->orderBy('position', 'ASC');
}
2nd RepairPart (has columns user_id and car_id)
This has function:
public function worker() {
return $this->belongsTo('AppWorker', 'worker_id');
}
3rd Car
This has function:
public function current_repair()
{
return $this->hasOne('AppCarRepair')->where('status', 0);
}
I want to create function in CarRepair model that would return me a list of CurrentRepair workers.
Sorry for my bad english. Hope you guys understood
from Laravel Questions and Answers https://laravelquestions.com/laravel/relations-help-laravel/
via Lzo Media
No comments:
Post a Comment