Reputation: 546
Heres is my code:
$data = Model::where('condition', $value)->get();
print_r($data);
How to get results only in eloquent? Its getting unnecessary keys.
$data['connection']
$data['guarded']
$data['etc.. etc etc...]
Upvotes: 1
Views: 113
Reputation: 163768
Use this to get all columns from Eloquent without any additional data:
$data = Model::where('condition', $value)->get()->toArray();
Or, if you need only some of the keys:
$data = Model::where('condition', $value)->get('valueIneed1', 'valueIneed2', 'valueIneed3')->toArray();
The thing is when you're using get()
, you're getting an eloquent collection
which contents a lot of additional data.
Upvotes: 4