Laravel makes communication with the database much easier with Eloquent. When working with Eloquent Relationships, when calling dynamic variables (using PHP's magic methods ), you should be aware that the instances of the models do not reflect new changes, but rather cache them permanently the first time they are called.
The following example behaves as expected:
6d32588c32f080ef1896633f261e1e14
$ model-> col always returns the old value even after the change (because the value was initially fetched once with Model :: find (42) and then saved). If you now address another, connected table with $ model-> dependent_table , you could expect that its second call would return the new value:
6d32588c32f080ef1896633f261e1e14
This is also not the case ( $ dependent_table = $ model-> dependant_table caches the entire dependent table). To get a current value, the explicitly defined function dependant_table () is called:
6d32588c32f080ef1896633f261e1e14