Laravel-medialibrary: Displaying media in Vue

Created on 5 Jun 2018  路  1Comment  路  Source: spatie/laravel-medialibrary

Hello!

I have just begun using this great package, I am trying to build a gallery in Vue in which you can hover over thumbnails and show the hovered image in full resolution. In Laravel I can easily do $model->getMedia() and in each object do $media->getFullUrl(), however in Vue that is not possible, I could generate all the URLs in the controller and send it to Vue, but I was wondering what approach you would use.

Thanks for the help!

Most helpful comment

We generally use Laravel API resources to transform a model to the representation needed on the front end.

https://laravel.com/docs/5.6/eloquent-resources

So kind of similar to your approach, just structured in a different way :)

Hope this helps!

>All comments

We generally use Laravel API resources to transform a model to the representation needed on the front end.

https://laravel.com/docs/5.6/eloquent-resources

So kind of similar to your approach, just structured in a different way :)

Hope this helps!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Krato picture Krato  路  4Comments

jam1e picture jam1e  路  3Comments

amrnn90 picture amrnn90  路  3Comments

kickthemooon picture kickthemooon  路  4Comments

intrepidws picture intrepidws  路  3Comments