如何解决Laravel 队列不工作,不显示错误
我想根据数据库中的 /public/storage
在 customer id
中创建客户的文件夹(由于服务器损坏)。我尝试使用 Laravel 队列。
这是我的代码。这只是创建文件夹。当我运行 php artisan queue:work
或 listen
时,我的终端上没有任何反应。
场景是:系统会根据customer id
创建一个文件夹名,并将文件夹保存到laravel/public/storage/uploads/file/folder
中
<?php
namespace App\Jobs;
use App\Model\Document;
use App\Model\Term;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\File;
class Restore implements ShouldQueue
{
use Dispatchable,InteractsWithQueue,Queueable,SerializesModels;
protected $folder;
public function __construct($folder)
{
$this->queue = 'default'; //choose a queue name
$this->connection = 'database';
$this->folder = $folder;
}
public function handle()
{
try {
ini_set('max_execution_time',300000);
$makedir = Term::get();
foreach ($makedir as $mkdir) {
$path = public_path().'/storage/uploads/file/'.$mkdir->id_praapplication;
$file_user = Document::get();
if(!(file_exists($path))) {
$folder = File::makeDirectory($path,$mode = 0777,true,true);
dispatch(new Restore($folder));
}
}
}
catch (\Exception $e) {
dd($e->getMessage());
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。