Is there any benefit to the following 2 pieces of code in a model class? Which one should I adopt and why?
public function emails()
{
return $this->hasMany('App\Email');
}
vs
public function emails()
{
return $this->hasMany(App\Email::class);
}
This works since PHP5.5 it returnes a String with the class name and its fully qualified namespace. The only benefit I know is thats it's better for Typehinting in the IDE.
There are more benefits than just Typehinting:
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community