I try to connect table with ORM. I have a 'Customers' table and 'Contacts'.
In my models I have write this :
class Customer extends Eloquent {
protected $fillable = [];
protected $softDelete = true;
protected $guarded = array();
public function contacts()
{
return $this->hasMany('Contact');
}
}
and this
class Contact extends Eloquent {
protected $fillable = [];
protected $softDelete = true;
protected $guarded = array();
public function customer()
{
return $this->belongsTo('Customer');
}
}
And in my controller when I try
return Customer::find($id)->contacts
I have no result :/
What I missing ?
Thank you
My Bad!
Ma database seeder save seed 140 customers and 35 contacts. I try to get the 140th contact...
My code works perfectly