Laravel Eloquent Accessing Original

I am trying to get a value from an object that I am getting from one of my models. It returns only those attributes that I do not need, because they do not match what is in my table. I want to access the source array.

I did:

$entries = Model::where('A', $A)->where('B', $B)->get(); @Foreach ($entries as $entry) $entry->id $entry->name @Endforeach 

I tried adding ->original , but it either doesn't work.

Here is partly the first entry of my var_dump($entries)

 ( [items:protected] => Array ( [0] => App\Models\TableA Object ( [table:protected] => Table A [primaryKey] => id [connection:protected] => [perPage:protected] => 15 [incrementing] => 1 [timestamps] => 1 [attributes:protected] => Array ( [id] => 1 [name] => 2 ) [original:protected] => Array ( [id] => 1 [name] => 1 ) 
+6
source share
2 answers

When you get the original attribute value of the Eloquent model, you can use getOriginal($key)

Link:

+15
source

For laravel 4.2 and on

 $entries->toArray() 

Will show only model attributes.

-1
source

Source: https://habr.com/ru/post/957644/


All Articles