Skip to content

Commit

Permalink
append url
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinGab committed Jan 10, 2024
1 parent 527c345 commit 151cc7b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Models/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Finller\Media\Traits\InteractsWithMediaFiles;
use Illuminate\Database\Eloquent\Casts\ArrayObject;
use Illuminate\Database\Eloquent\Casts\AsArrayObject;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphTo;
Expand Down Expand Up @@ -52,6 +53,8 @@ class Media extends Model
*/
protected $guarded = [];

protected $appends = ['url'];

/**
* @var array<string, string>
*/
Expand All @@ -76,6 +79,11 @@ public function model(): MorphTo
return $this->morphTo();
}

protected function url(): Attribute
{
return Attribute::get(fn () => $this->getUrl());
}

public function getConversionKey(string $conversion): string
{
return str_replace('.', '.generated_conversions.', $conversion);
Expand Down

0 comments on commit 151cc7b

Please sign in to comment.