mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-14 01:31:06 +03:30
fix media
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Media;
|
||||||
|
|
||||||
|
use Spatie\MediaLibrary\Models\Media;
|
||||||
|
use Spatie\MediaLibrary\PathGenerator\PathGenerator as BasePathGenerator;
|
||||||
|
|
||||||
|
class PathGenerator implements BasePathGenerator
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the path for the given media, relative to the root storage path.
|
||||||
|
*/
|
||||||
|
public function getPath(Media $media): string
|
||||||
|
{
|
||||||
|
return md5($media->id).'/';
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the path for conversions of the given media, relative to the root storage path.
|
||||||
|
*/
|
||||||
|
public function getPathForConversions(Media $media): string
|
||||||
|
{
|
||||||
|
return $this->getPath($media).'conversions/';
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the path for responsive images of the given media, relative to the root storage path.
|
||||||
|
*/
|
||||||
|
public function getPathForResponsiveImages(Media $media): string
|
||||||
|
{
|
||||||
|
return $this->getPath($media).'responsive-images/';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Services\Media\Resources;
|
namespace App\Services\Media\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
class MediaResource extends JsonResource
|
class MediaResource extends JsonResource
|
||||||
@@ -9,7 +10,7 @@ class MediaResource extends JsonResource
|
|||||||
/**
|
/**
|
||||||
* Transform the resource into an array.
|
* Transform the resource into an array.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param Request $request
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function toArray($request)
|
public function toArray($request)
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Media\UrlGenerator;
|
||||||
|
|
||||||
|
use DateTimeInterface;
|
||||||
|
use Spatie\MediaLibrary\UrlGenerator\BaseUrlGenerator;
|
||||||
|
use Spatie\MediaLibrary\Exceptions\UrlCannotBeDetermined;
|
||||||
|
|
||||||
|
class FtpUrlGenerator extends BaseUrlGenerator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the url for the profile of a media item.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUrl() : string
|
||||||
|
{
|
||||||
|
return config('media-library.wm-cdn').'/'.$this->getPathRelativeToRoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTimeInterface $expiration
|
||||||
|
* @param array $options
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @throws UrlCannotBeDetermined
|
||||||
|
*/
|
||||||
|
public function getTemporaryUrl(DateTimeInterface $expiration, array $options = []): string
|
||||||
|
{
|
||||||
|
throw UrlCannotBeDetermined::filesystemDoesNotSupportTemporaryUrls();
|
||||||
|
return 'done';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the relative path for the profile of a media item.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function getPath()
|
||||||
|
{
|
||||||
|
return $this->getPathRelativeToRoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the url to the directory containing responsive images.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getResponsiveImagesDirectoryUrl(): string
|
||||||
|
{
|
||||||
|
return config('media-library.wm-cdn').'/'.$this->pathGenerator->getPathForResponsiveImages($this->media);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Media\UrlGenerator;
|
||||||
|
|
||||||
|
use DateTimeInterface;
|
||||||
|
use Spatie\MediaLibrary\UrlGenerator\BaseUrlGenerator;
|
||||||
|
|
||||||
|
|
||||||
|
class S3UrlGenerator extends BaseUrlGenerator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the url for the profile of a media item.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUrl() : string
|
||||||
|
{
|
||||||
|
return config('media-library.s3.domain').'/'.$this->getPathRelativeToRoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTimeInterface $expiration
|
||||||
|
* @param array $options
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function getTemporaryUrl(DateTimeInterface $expiration, array $options = []): string
|
||||||
|
{
|
||||||
|
|
||||||
|
return 'done';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the relative path for the profile of a media item.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function getPath(): string
|
||||||
|
{
|
||||||
|
return $this->getPathRelativeToRoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the url to the directory containing responsive images.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getResponsiveImagesDirectoryUrl(): string
|
||||||
|
{
|
||||||
|
return config('media-library.s3.domain').'/'.$this->pathGenerator->getPathForResponsiveImages($this->media);
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+24
-23
@@ -62,16 +62,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "aws/aws-sdk-php",
|
"name": "aws/aws-sdk-php",
|
||||||
"version": "3.293.5",
|
"version": "3.293.7",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/aws/aws-sdk-php.git",
|
"url": "https://github.com/aws/aws-sdk-php.git",
|
||||||
"reference": "f2002e52b382b45231da3f9552033f769acfebd8"
|
"reference": "3bf86ba8b9bbea2b298f89e6f5edc58de276690b"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/f2002e52b382b45231da3f9552033f769acfebd8",
|
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/3bf86ba8b9bbea2b298f89e6f5edc58de276690b",
|
||||||
"reference": "f2002e52b382b45231da3f9552033f769acfebd8",
|
"reference": "3bf86ba8b9bbea2b298f89e6f5edc58de276690b",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -151,9 +151,9 @@
|
|||||||
"support": {
|
"support": {
|
||||||
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
|
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
|
||||||
"issues": "https://github.com/aws/aws-sdk-php/issues",
|
"issues": "https://github.com/aws/aws-sdk-php/issues",
|
||||||
"source": "https://github.com/aws/aws-sdk-php/tree/3.293.5"
|
"source": "https://github.com/aws/aws-sdk-php/tree/3.293.7"
|
||||||
},
|
},
|
||||||
"time": "2023-12-06T19:09:15+00:00"
|
"time": "2023-12-08T19:11:21+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "carbonphp/carbon-doctrine-types",
|
"name": "carbonphp/carbon-doctrine-types",
|
||||||
@@ -7614,23 +7614,23 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "tijsverkoyen/css-to-inline-styles",
|
"name": "tijsverkoyen/css-to-inline-styles",
|
||||||
"version": "2.2.6",
|
"version": "v2.2.7",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/tijsverkoyen/CssToInlineStyles.git",
|
"url": "https://github.com/tijsverkoyen/CssToInlineStyles.git",
|
||||||
"reference": "c42125b83a4fa63b187fdf29f9c93cb7733da30c"
|
"reference": "83ee6f38df0a63106a9e4536e3060458b74ccedb"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/c42125b83a4fa63b187fdf29f9c93cb7733da30c",
|
"url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/83ee6f38df0a63106a9e4536e3060458b74ccedb",
|
||||||
"reference": "c42125b83a4fa63b187fdf29f9c93cb7733da30c",
|
"reference": "83ee6f38df0a63106a9e4536e3060458b74ccedb",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"ext-dom": "*",
|
"ext-dom": "*",
|
||||||
"ext-libxml": "*",
|
"ext-libxml": "*",
|
||||||
"php": "^5.5 || ^7.0 || ^8.0",
|
"php": "^5.5 || ^7.0 || ^8.0",
|
||||||
"symfony/css-selector": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0"
|
"symfony/css-selector": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0 || ^7.5 || ^8.5.21 || ^9.5.10"
|
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0 || ^7.5 || ^8.5.21 || ^9.5.10"
|
||||||
@@ -7661,9 +7661,9 @@
|
|||||||
"homepage": "https://github.com/tijsverkoyen/CssToInlineStyles",
|
"homepage": "https://github.com/tijsverkoyen/CssToInlineStyles",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/tijsverkoyen/CssToInlineStyles/issues",
|
"issues": "https://github.com/tijsverkoyen/CssToInlineStyles/issues",
|
||||||
"source": "https://github.com/tijsverkoyen/CssToInlineStyles/tree/2.2.6"
|
"source": "https://github.com/tijsverkoyen/CssToInlineStyles/tree/v2.2.7"
|
||||||
},
|
},
|
||||||
"time": "2023-01-03T09:29:04+00:00"
|
"time": "2023-12-08T13:03:43+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "vlucas/phpdotenv",
|
"name": "vlucas/phpdotenv",
|
||||||
@@ -8655,29 +8655,29 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpspec/prophecy",
|
"name": "phpspec/prophecy",
|
||||||
"version": "v1.17.0",
|
"version": "v1.18.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/phpspec/prophecy.git",
|
"url": "https://github.com/phpspec/prophecy.git",
|
||||||
"reference": "15873c65b207b07765dbc3c95d20fdf4a320cbe2"
|
"reference": "d4f454f7e1193933f04e6500de3e79191648ed0c"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/15873c65b207b07765dbc3c95d20fdf4a320cbe2",
|
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/d4f454f7e1193933f04e6500de3e79191648ed0c",
|
||||||
"reference": "15873c65b207b07765dbc3c95d20fdf4a320cbe2",
|
"reference": "d4f454f7e1193933f04e6500de3e79191648ed0c",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"doctrine/instantiator": "^1.2 || ^2.0",
|
"doctrine/instantiator": "^1.2 || ^2.0",
|
||||||
"php": "^7.2 || 8.0.* || 8.1.* || 8.2.*",
|
"php": "^7.2 || 8.0.* || 8.1.* || 8.2.* || 8.3.*",
|
||||||
"phpdocumentor/reflection-docblock": "^5.2",
|
"phpdocumentor/reflection-docblock": "^5.2",
|
||||||
"sebastian/comparator": "^3.0 || ^4.0",
|
"sebastian/comparator": "^3.0 || ^4.0 || ^5.0",
|
||||||
"sebastian/recursion-context": "^3.0 || ^4.0"
|
"sebastian/recursion-context": "^3.0 || ^4.0 || ^5.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpspec/phpspec": "^6.0 || ^7.0",
|
"phpspec/phpspec": "^6.0 || ^7.0",
|
||||||
"phpstan/phpstan": "^1.9",
|
"phpstan/phpstan": "^1.9",
|
||||||
"phpunit/phpunit": "^8.0 || ^9.0"
|
"phpunit/phpunit": "^8.0 || ^9.0 || ^10.0"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
@@ -8710,6 +8710,7 @@
|
|||||||
"keywords": [
|
"keywords": [
|
||||||
"Double",
|
"Double",
|
||||||
"Dummy",
|
"Dummy",
|
||||||
|
"dev",
|
||||||
"fake",
|
"fake",
|
||||||
"mock",
|
"mock",
|
||||||
"spy",
|
"spy",
|
||||||
@@ -8717,9 +8718,9 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/phpspec/prophecy/issues",
|
"issues": "https://github.com/phpspec/prophecy/issues",
|
||||||
"source": "https://github.com/phpspec/prophecy/tree/v1.17.0"
|
"source": "https://github.com/phpspec/prophecy/tree/v1.18.0"
|
||||||
},
|
},
|
||||||
"time": "2023-02-02T15:41:36+00:00"
|
"time": "2023-12-07T16:22:33+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpstan/phpdoc-parser",
|
"name": "phpstan/phpdoc-parser",
|
||||||
|
|||||||
Reference in New Issue
Block a user