Magento, Laravel, Eloquent.
return $this->belongsTo(Category::class); } public function url() { return URL::route('product', [ 'category' => $this->category->slug, 'product' => $this->slug, ]); } } In this model, we have a helper function that uses the related category slug to generate the URL, a simple but useful method in