mercredi 25 avril 2018

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('App\RepairPart', 'repair_id')->orderBy('position', 'ASC');
}

2nd RepairPart (has columns user_id and car_id)

This has function:

public function worker() {
return $this->belongsTo('App\Worker', 'worker_id');
}

3rd Car

This has function:

public function current_repair()
{
return $this->hasOne('App\CarRepair')->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 :)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire