Add laravel-medialibrary for avatars

This commit is contained in:
Nabeel Shahzad
2018-04-02 17:49:04 -05:00
parent 0f98e729ce
commit 36a7886668
6 changed files with 743 additions and 53 deletions

View File

@@ -0,0 +1,49 @@
<?php
/**
*
*/
namespace App\Support\Media;
use DateTimeInterface;
use Spatie\MediaLibrary\Exceptions\UrlCannotBeDetermined;
use Spatie\MediaLibrary\UrlGenerator\BaseUrlGenerator;
/**
* Class PublicUrlGenerator
* @package App\Support\Media
*/
class PublicUrlGenerator extends BaseUrlGenerator
{
/**
* Get the url for the profile of a media item.
* @return string
*/
public function getUrl(): string
{
return public_asset($this->getPathRelativeToRoot());
}
/**
* Get the temporary url for a media item.
*
* @param DateTimeInterface $expiration
* @param array $options
*
* @return string
*/
public function getTemporaryUrl(DateTimeInterface $expiration, array $options = []): string
{
throw UrlCannotBeDetermined::filesystemDoesNotSupportTemporaryUrls();
}
/**
* Get the url to the directory containing responsive images.
*
* @return string
*/
public function getResponsiveImagesDirectoryUrl(): string
{
return public_asset('/').'/'.$this->pathGenerator->getPathForResponsiveImages($this->media);
}
}