Issues (42)

src/Jobs/UploadImage.php (3 issues)

Labels
1
<?php
2
3
namespace FaithGen\Sermons\Jobs;
4
5
use FaithGen\SDK\Traits\UploadsImages;
6
use FaithGen\Sermons\Models\Sermon;
7
use Illuminate\Bus\Queueable;
8
use Illuminate\Contracts\Queue\ShouldQueue;
9
use Illuminate\Foundation\Bus\Dispatchable;
10
use Illuminate\Queue\InteractsWithQueue;
11
use Illuminate\Queue\SerializesModels;
12
use Intervention\Image\ImageManager;
13
14
class UploadImage implements ShouldQueue
15
{
16
    use Dispatchable,
0 ignored issues
show
The trait Illuminate\Queue\SerializesModels requires some properties which are not provided by FaithGen\Sermons\Jobs\UploadImage: $id, $relations, $class, $keyBy
Loading history...
The trait FaithGen\SDK\Traits\UploadsImages requires the property $id which is not provided by FaithGen\Sermons\Jobs\UploadImage.
Loading history...
17
        InteractsWithQueue,
18
        Queueable,
19
        SerializesModels,
20
        UploadsImages;
21
22
    public bool $deleteWhenMissingModels = true;
23
    protected Sermon $sermon;
24
25
    protected string $image;
26
27
    /**
28
     * Create a new job instance.
29
     *
30
     * @param Sermon $sermon
31
     * @param string $image
32
     */
33
    public function __construct(Sermon $sermon, string $image)
34
    {
35
        $this->sermon = $sermon;
36
        $this->image = $image;
37
    }
38
39
    /**
40
     * Execute the job.
41
     *
42
     * @param ImageManager $imageManager
43
     *
44
     * @return void
45
     */
46
    public function handle(ImageManager $imageManager)
47
    {
48
        if ($this->sermon->image()->exists()) {
49
            $fileName = $this->sermon->image->name;
0 ignored issues
show
The property image does not seem to exist on FaithGen\Sermons\Models\Sermon. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
50
            $this->uploadImages($this->sermon, [$this->image], $imageManager, $fileName);
51
        } else {
52
            $this->uploadImages($this->sermon, [$this->image], $imageManager);
53
        }
54
    }
55
}
56