Initial Commit
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Story;
|
||||
|
||||
class StoryMediaCacher extends MediaCacher
|
||||
{
|
||||
public function cache(Story $story): void
|
||||
{
|
||||
$dirty = false;
|
||||
|
||||
if ($resolved = $this->resolveUrl($story->image_url, "stories/images/{$story->id}")) {
|
||||
$story->image_url = $resolved;
|
||||
$dirty = true;
|
||||
}
|
||||
|
||||
if ($resolved = $this->resolveUrl($story->video_url, "stories/videos/{$story->id}")) {
|
||||
$story->video_url = $resolved;
|
||||
$dirty = true;
|
||||
}
|
||||
|
||||
if ($dirty) {
|
||||
$story->saveQuietly();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user