From b799ee6c748ff9116c29402e36616681c8b182c3 Mon Sep 17 00:00:00 2001 From: Kekskurse Date: Sun, 17 Jan 2021 03:20:21 +0100 Subject: [PATCH] Stuff --- app/Console/Commands/ImageCacheAll.php | 51 +++++++++++++++++++++++ app/Console/Kernel.php | 4 +- app/Http/Controllers/PublicController.php | 6 +-- 3 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 app/Console/Commands/ImageCacheAll.php diff --git a/app/Console/Commands/ImageCacheAll.php b/app/Console/Commands/ImageCacheAll.php new file mode 100644 index 0000000..fc82342 --- /dev/null +++ b/app/Console/Commands/ImageCacheAll.php @@ -0,0 +1,51 @@ +get(); + foreach ($images as $image) { + foreach (PublicController::$size as $size) { + $this->info("Cache ".$image->id." as ".$size); + ResizeImage::dispatchSync($image->id, $size); + } + } + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 5a7fea5..2eab6d2 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -4,6 +4,7 @@ namespace App\Console; use App\Console\Commands\CalculateSpace; use App\Console\Commands\CalculateTraffic; +use App\Console\Commands\ImageCacheAll; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; @@ -16,7 +17,8 @@ class Kernel extends ConsoleKernel */ protected $commands = [ CalculateSpace::class, - CalculateTraffic::class + CalculateTraffic::class, + ImageCacheAll::class ]; /** diff --git a/app/Http/Controllers/PublicController.php b/app/Http/Controllers/PublicController.php index 8538192..53abc70 100644 --- a/app/Http/Controllers/PublicController.php +++ b/app/Http/Controllers/PublicController.php @@ -21,12 +21,8 @@ use phpDocumentor\Reflection\Types\Integer; class PublicController extends BaseController { - const SIZE_SMALL = 300; - const SIZE_MEDIUM = 600; - const SIZE_BIG = 1200; - const SIZE_PIXEL = 100; + public static $size = ["pixel" => 100, "small" => 300, "medium" => 600, "big" => 1200]; - private $size = ["pixel" => 100, "small" => 300, "medium" => 600, "big" => 1200]; use AuthorizesRequests, DispatchesJobs, ValidatesRequests; public function listGalleriesView($name) {