Actually I don't have idea what is difference in both methods
Laravel Official documentation uses this below method for declaring relationship
class User extends Model
{
public function phone()
{
return $this->hasOne('App\Phone'); // HERE (App\Phone) Parameter
}
}
and most of the tutorials and experts (even in Laracon's) uses this below method.
class User extends Model
{
public function phone()
{
return $this->hasOne(Phone::class); // HERE (Phone::class) Parameter
}
}
In short what is difference in both, And which is convenient.
return $this->hasOne(Phone::class); // Method one
/// VS
return $this->hasOne('App\Phone'); // Method Two