Getting specific columns with eager loading laravel 4

前端 未结 2 1671
执念已碎
执念已碎 2020-12-06 03:43

I am new to laravel and making a basic application to get a grip on relationships.I have implemented one to one relationship and want to get specific columns from both the b

2条回答
  •  广开言路
    2020-12-06 04:14

    One of the solution would be just making a new relation similar to that you have made, but tweaking it a bit, for conviniece :

    public function identity_cards_limited() 
        {
            return $this->hasOne('IdentityCard')->select('desired_column');
        }
    

提交回复
热议问题