jeudi 22 février 2018

Search based on foreign key in Laravel

Laravel 5.*

I have the Case Model that has one to one relationship with Customer Model as defined below:

public function customer
{
   return $this->hasOne(Customer::class, 'id', 'customer');
}

In the cases listing (cases.index), it displays the customer name based on relationship $case->customer->name.

I am trying to create search and list all the cases based on customer name.

Is there a native way to search based on the relationship?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire