Fantastic package and outstanding quality. One remark. Is it possible to eager load the url?
collection_name: "images"
created_at: "2019-01-15 15:35:00"
custom_properties: []
disk: "public"
file_name: "background.jpg"
id: 1
manipulations: []
mime_type: "image/jpeg"
model_id: 40
model_type: "App\Item"
name: "background"
order_column: 1
responsive_images: []
size: 247634
updated_at: "2019-01-15 15:35:00"
also the URL
you could define an accesor getUrlAttribute and add it to $appents variable. Than: the toArray() will return also this value
you could define an accesor
getUrlAttributeand add it to $appents variable. Than: the toArray() will return also this value
Thanks very much! That solved my problem!
I implemented a custom class as explained here:
https://docs.spatie.be/laravel-medialibrary/v7/advanced-usage/using-your-own-model
And then added the url as shown below:
<?php
namespace App;
use Spatie\MediaLibrary\Models\Media as BaseMedia;
class Media extends BaseMedia
{
protected $appends = ['url'];
public function getUrlAttribute()
{
return $this->getUrl();
}
}
Most helpful comment
Thanks very much! That solved my problem!
I implemented a custom class as explained here:
https://docs.spatie.be/laravel-medialibrary/v7/advanced-usage/using-your-own-model
And then added the url as shown below: