1 | <?php |
||
13 | class ProcessImage implements ShouldQueue |
||
14 | { |
||
15 | use Dispatchable, |
||
16 | InteractsWithQueue, |
||
17 | Queueable, |
||
18 | SerializesModels; |
||
19 | |||
20 | public bool $deleteWhenMissingModels = true; |
||
|
|||
21 | protected News $article; |
||
22 | |||
23 | /** |
||
24 | * Create a new job instance. |
||
25 | * |
||
26 | * @param News $article |
||
27 | */ |
||
28 | public function __construct(News $article) |
||
29 | { |
||
30 | $this->article = $article; |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * Execute the job. |
||
35 | * |
||
36 | * @param ImageManager $imageManager |
||
37 | * |
||
38 | * @return void |
||
39 | */ |
||
40 | public function handle(ImageManager $imageManager) |
||
41 | { |
||
42 | if ($this->article->image()->exists()) { |
||
43 | $ogImage = storage_path('app/public/news/original/').$this->article->image->name; |
||
44 | $thumb100 = storage_path('app/public/news/100-100/').$this->article->image->name; |
||
45 | |||
46 | $imageManager->make($ogImage)->fit(100, 100, function ($constraint) { |
||
47 | $constraint->upsize(); |
||
48 | $constraint->aspectRatio(); |
||
53 |