Laravel по-русски

Русское сообщество разработки на PHP-фреймворке Laravel.

Ты не вошёл. Вход тут.

#1 14.02.2019 17:16:49

Не обрабатываются в очереди изображения InterventionImage

Laravel 5.7, Php 7.1

public function handle()
    {
        $file = fopen(__DIR__ . '/../../public/storage/brushes/text.txt', 'a');
        fputs($file, $this->txt . PHP_EOL);
        fclose($file);


        $img = Image::make($this->path1);
        $img->resize(150, 60);
        $img->mask("storage/brushes/$this->direct/00$this->idf.png");
        $img->save(public_path($this->path2));
    }

Первая часть кода - тестовая, что бы видеть, выполнилась ли хотя бы часть очереди.
Если процесс идёт через Sync - то всё гладко: строчка прописывается, изображение сохраняется.

Если через БД, то выдаёт 256 попыток, первая часть кода добавляет 256 строчек, с изображением не происходит ничего. Не могу разобраться что не так. Заранее спасибо за любую помощь.

Не в сети

#2 14.02.2019 17:28:00

Re: Не обрабатываются в очереди изображения InterventionImage

Controller fragment:

$direct = null;

            if (PostOptionBufer::all()->first()->template == 1) {
                $direct = 'Horizontal';
            } else {
                $direct = 'Vertical';
            }

            $idf = PostOptionBufer::all()->first()->form;
            $path1 = 'storage/temp/brush.jpg';
            $path2 = 'storage/brushes/temp.png';

            $txt = 'pzzzzzzz';

            dispatch(new MakeBrush($direct, $idf, $txt, $path1, $path2));

Job full

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Intervention\Image\Facades\Image;

class MakeBrush implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $txt;
    protected $direct;
    protected $idf;
    protected $path1;
    protected $path2;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($direct, $idf, $txt, $path1, $path2)
    {
        $this->txt = $txt;
        $this->direct = $direct;
        $this->idf = $idf;
        $this->path1 = $path1;
        $this->path2 = $path2;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $file = fopen(__DIR__ . '/../../public/storage/brushes/text.txt', 'a');
        fputs($file, $this->txt . PHP_EOL);
        fclose($file);


        $img = Image::make($this->path1);
        $img->resize(150, 60);
        $img->mask("storage/brushes/$this->direct/00$this->idf.png");
        $img->save(public_path($this->path2));
    }
}

Не в сети

Подвал раздела