Paul Couture
b14a77762d
Reviewed-on: #7 Co-authored-by: Paul Couture <paul@paulcouture.com> Co-committed-by: Paul Couture <paul@paulcouture.com>
37 lines
794 B
PHP
37 lines
794 B
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use ImageOptimizer;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class OptimizeAvatarJob implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
private $path;
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*/
|
|
public function __construct($path)
|
|
{
|
|
$this->path = $path;
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*/
|
|
public function handle(): void
|
|
{
|
|
Log::info('Avatar: Optimizing ' . $this->path);
|
|
ImageOptimizer::optimize($this->path);
|
|
}
|
|
}
|