32 lines
807 B
PHP
32 lines
807 B
PHP
<?php
|
|
|
|
namespace App\Repositories\Core;
|
|
|
|
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
|
use Spatie\MediaLibrary\Support\PathGenerator\PathGenerator;
|
|
|
|
class MediaPathGenerator implements PathGenerator
|
|
{
|
|
public function getPath(Media $media): string
|
|
{
|
|
return $this->getBasePath($media).'/';
|
|
}
|
|
|
|
public function getPathForConversions(Media $media): string
|
|
{
|
|
return $this->getBasePath($media).'/conversions/';
|
|
}
|
|
|
|
public function getPathForResponsiveImages(Media $media): string
|
|
{
|
|
return $this->getBasePath($media).'/responsive-images/';
|
|
}
|
|
|
|
protected function getBasePath(Media $media): string
|
|
{
|
|
$model = basename(str_replace('\\', '/', $media->model_type));
|
|
|
|
return basename($model).'/images/'.$media->getKey();
|
|
}
|
|
}
|