My problem is, I want to add a relationship on pdrn_table to client_service_order_table then client_service_order_table to client_users_table.
My tables are:
pdrn_table
- service_order_no
- name
client_service_order_table
- service_order_no
- client_user_id
- job_status
client_users_table
- client_user_id
- name
I already added a relationship on pdrn_table to client_service_order_table my code is like this.
PdrnRequest Model
class PdrnRequest extends Model
{
public function clientServiceOrder()
{
return $this->hasOne('App\Models\ClientServiceOrder', 'service_order_no', 'service_order_no');
}
}
then my eloquent query is like this
return PdrnRequest::with('clientServiceOrder')
->take(10)
->get();
now how can i add a relationship on client_users_table?
I tried to add a relationship on ClientServiceOrder Model but i don't know how to add this relationship on my previous eloquent query.
class ClientServiceOrder extends Model
{
public function client()
{
return $this->hasOne('App\Models\ClientUsers', 'client_user_id', 'client_user_id');
}
}
Please help! Thanks.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2s1UVya
via IFTTT
Aucun commentaire:
Enregistrer un commentaire