Код: Выделить всё
try {
importProductsFromPlatform::dispatch($api, $options);
// dispatch(new importProductsFromPlatform($api, $options));
} catch (\Throwable $th) {
$txt = "\n".'dispatching error: '.print_r($th->getMessage(), true);
file_put_contents(storage_path('logs/import_products.log'), $txt.PHP_EOL , FILE_APPEND | LOCK_EX);
}
Код: Выделить всё
namespace App\Jobs;
use App\Models\ApiClient;
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;
class importProductsFromPlatform implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected ApiClient $api;
protected $options = null;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(ApiClient $api, $options = null)
{
$this->api = $api;
$this->options = $options;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$txt = "\n".'handling import, options: '.print_r($this->options, true);
file_put_contents(storage_path('logs/import_products.log'), $txt.PHP_EOL , FILE_APPEND | LOCK_EX);
$this->api->helper()->parse_remote_products($this->options);
}
}
Так что же я делаю не так? Как я могу выполнить работу без команды терминала?
Подробнее здесь: https://stackoverflow.com/questions/786 ... by-laravel
Мобильная версия