ziggy: Ziggy v0.4.0 & v0.4.1 returns an object instead of string

I tried Ziggy in Laravel 5.5 and it is returning an object instead of the full URL of the route like so

route('admin.articles.index')
// laravel 5.4 returns
"http://blog.dev/admin/articles"

// laravel 5.5 returns
{
  "name": "admin.articles.index",
  "urlParams": {},
  "queryParams": {},
  "absolute": true,
  "domain": "http://blog.dev/",
  "url": "admin/articles"
}

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 32 (9 by maintainers)

Most upvoted comments

@AidasK What about route('index').toString()? Does it return any thing?

Yes, it returns my route url. This is the solution I am currently using, but it’s not short enough.

@mgsmus, I’m using @routes annotation with Laravel 5.5 without issue. That’s strange?

@the94air Right now you can use a computed property or method that will automatically call toString() for you with the route, for example:

computed: {
    indexUrl()
    {
        return route('posts.index'):
    },
},

methods: {
    viewUrl(post)
    {
        return route('posts.show', post);
    }
},
<a :href="indexUrl">All Posts</a>

<a :href="viewUrl(post)">View Post</a>

Oh makes sense. No problem glad you got it sorted.