<?php
class Product extends Eloquent {
protected appends = array('category');
public function category()
{
return $this->belongsTo('Models\Category',
'category_id');
}
}
How to achieve that ?
<?php
class Product extends Eloquent {
protected $with = array('category');
//protected $appends = array('category');
public function category()
{
return $this->belongsTo('Models\Category',
'category_id');
}
}
Define a $with
property instead of $appends
property. It is an eager load.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With