【发布时间】:2014-03-14 16:44:21
【问题描述】:
我正在尝试隐藏关于多对多关系的列,但目前没有成功。 我有:
Square.php
public function sitesquares() {
//Trying to use select() but no success
return $this->belongsToMany('Sitesquare', 'square_site', 'square_id', 'site_id')->select( array('square_id','site_id', 'sites.site_name') );
}
Sitesquare.php
public function squares()
{
return $this->belongsToMany('Square', 'square_site');
}
方形控制器
$sites = Square::with(array('sitesquares'=>function ($q)
{
$q->select(array('site_name')); //also don't work
}))->get();
return $sites; //json
有人请,还有其他解决方案吗?
【问题讨论】:
标签: php laravel laravel-4 eloquent