vendredi 3 juillet 2020

Relationships beetween 3 Tables without pivot tabel

Hello I'have a problem with relationship in Laravel 5.5.

I have 3 tables with these keys:

Customers
 - id

Activities
- customer

Tasks
- activity_id

I want, from Model Task get related Customer.

I tried with this from Task Model:

public function customer(){
   return $this->hasManyThrough( 'App\Models\Customers',"App\Models\Activities", "customer", "id", "activity_id");
       
}

I tried also:

public function customer(){
       return $this->hasManyThrough( 'App\Models\Customers',"App\Models\Activities", "customer", "id", "id", "activity_id");
           
    }

But it return empty array, and I'm sure that it should not be empty.

How Can I make a relationship like this with eloquent?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire