Ken*_*iau 4 laravel eloquent laravel-4
<?php
class Product extends Eloquent {
protected appends = array('category');
public function category()
{
return $this->belongsTo('Models\Category',
'category_id');
}
}
Run Code Online (Sandbox Code Playgroud)
如何实现呢?
<?php
class Product extends Eloquent {
protected $with = array('category');
//protected $appends = array('category');
public function category()
{
return $this->belongsTo('Models\Category',
'category_id');
}
}
Run Code Online (Sandbox Code Playgroud)
定义一个$with属性而不是$appends属性。这是一个渴望的负担。
| 归档时间: |
|
| 查看次数: |
2144 次 |
| 最近记录: |