Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

When models related data called : at new instance / call alias

Hello Team

i have a question about relationship in models

for example i set up model Test like : Test::class -> hasMany( a , Realted::class , b , [ alias => related ] )

does related data fetched at beginning of model call or after calling test.related ?


It's lazy, so the query to retrieve the related models doesn't happen until you call $TestObject->related.

Ok ! That's useful to know

thanks !