In this example, I have a Reward model, and I'm defining a relationship to a category. Which is better practice, and why?
Referencing the relationship statically:
public function category() {
return $this->belongsTo(Category::class, 'category');
}
or via a string:
public function category() {
return $this->belongsTo('App\Category`, 'category');
}
I would think the string method makes more sense since there isn't a direct reference to another model, but I could be wrong. I want to make sure things are setup properly according to best standards, but couldn't find an opinion on this anywhere.