In this example code here:
public function user()
{
return $this->belongsTo(User::class);
}
public function sandwich()
{
return $this->belongsTo(Sandwich::class);
}
I want to know what User::class
is called, because you could also write that above example like this:
public function user()
{
return $this->belongsTo(\App\User);
}
public function sandwich()
{
return $this->belongsTo(\App\Sandwich);
}
So I like that Laravel "just knows" where the model is when you use that syntax sugar, but what is it called? I'd like to read some documentation about it so I better understand what's happening behind the scenes.
It reminds me in some ways of "route model binding", so the answer that I would like is a link to the relevant docs page somewhere, or a term I can Google to understand what exactly is going on there.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire