samedi 12 juin 2021

How does Laravel resolve some methods in models?

I wanna know how laravel can find and how it work some method like realtions method

(1:1 & 1:M )


for e.g in User Model i have one to many relation with My Post Model

public function posts(){
return $this->hasMany(Post::class);
}

and when i want to get some user posts data i will use this code

$user = User::find(1);
$user->posts();

here is my question $user->posts(); how laravel can find and reslove it



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire