I have the following model.
class Property extends Model
{
public function bedroom()
{
return $this->hasOne('App\Models\Bedroom');
}
public function week()
{
return $this->hasMany('App\Models\Week');
}
}
I then sometimes eager load the week and sometimes do not.
I.e.
$property = Property::with('bedroom');
Later my code had the following line:
if (isset($property->week)) {
Now this worked fine before I ran composer update. As I hadn't eager loaded week, the IF statement would return false. If I did a DD dump, I could see that $property does not contain the relation Week.
Since running composer update, this line now works differently and eager loads the weeks, making the if statement always true. If I do a DD dump after the IF statement, it now shows the Week relation. By asking if the relation exists, it is loading the relation.
Composer Update updated the framework from 5.1.28 to 5.1.43
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire