【发布时间】:2017-10-17 06:10:45
【问题描述】:
我有 2 个表“项目”和“品牌”。 items 包含产品详细信息,例如 item_id、name 和 brand_id,而brands 包含 brandId 和 brand_name。我想获取可以加入品牌和商品的商品数据。
这是我的控制器。
public function filters($id){
$items = Items::brands();
return $items;
}
这是我的模型。
public static function brands(){
return $this->hasOne('App\Brands');
}
我在浏览器上运行时得到以下信息。 不在对象上下文中时使用 $this
【问题讨论】:
-
你有一个静态方法并且你在其中使用了 $this 你认为会发生什么?
标签: php database join orm laravel-5.4