Laravel Eloquent: How to get only certain columns from joined tables

前端 未结 15 2547
礼貌的吻别
礼貌的吻别 2020-12-02 07:57

I have got 2 joined tables in Eloquent namely themes and users.

theme model:

public function user() {
  return $this->belongs_to(         


        
15条回答
  •  北荒
    北荒 (楼主)
    2020-12-02 08:27

    In Laravel 4 you can hide certain fields from being returned by adding the following in your model.

    protected $hidden = array('password','secret_field');
    

    http://laravel.com/docs/eloquent#converting-to-arrays-or-json

提交回复
热议问题