123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace App\Jobs;
- use App\Models\LibraryCategory;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Bus\Dispatchable;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Queue\SerializesModels;
- use Illuminate\Support\Facades\Storage;
- use SimpleSoftwareIO\QrCode\Facades\QrCode;
- class MakeCodeJob implements ShouldQueue
- {
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- private $cid = 0;
- /**
- * Create a new job instance.
- *
- * @return void
- */
- public function __construct($cid)
- {
- $this->cid = $cid;
- }
- /**
- * Execute the job.
- *
- * @return void
- */
- public function handle()
- {
- if ($this->cid) {
- $id = $this->cid;
- $code = QrCode::format('png')->size(600)->generate(config('app.code_url') . "?cid={$id}");
- $file_path = "codes/{$id}.png";
- Storage::disk(config('admin.upload.disk'))->put($file_path, $code);
- LibraryCategory::query()->where('id', $id)->update([
- 'code_path' => $file_path
- ]);
- }
- }
- }
|