2 weeks ago

Path Function for URL With ID and Slug

Posted 2 weeks ago by moshemo

I am referencing this episode:

In that episode, Jeffrey creates the following function in the Article model:

  public function path() {
    return route('', $this);

Now, this works just fine and returns the following url structure:{id}

However, I would like to tweak it a bit. I want my url structure to be like this:{id}/{slug}

So, what I want to know is how do I have to modify the path function in order to return this url structure - i.e., the one with both the id and the slug?

Please sign in or create an account to participate in this conversation.