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) {