Yep - your relationship methods should have returns on them:
public function invoiceDetails()
{
return $this->hasMany('Invoice_detail');
}
I must be missing something obvious. I've got a Invoice_detail Model:
class Invoice_detail extends Eloquent {
public function products()
{
$this->belongsTo('Product');
}
}
A Product Model:
class Product extends Eloquent {
public function invoiceDetails()
{
$this->hasMany('Invoice_detail');
}
}
but when I try to use this:
Route::get('/', function(){
$detail = Invoice_detail::whereId(27)->first();
return $detail->products;
});
I get: Relationship method must return an object of type Illuminate\Database\Eloquent\Relations\Relation
What am I missing here?