Issues (15)

src/Jobs/WritePdf.php (1 issue)

Severity
1
<?php
2
3
namespace LWS\ExportActions\Jobs;
4
5
use PDF;
6
use Illuminate\Bus\Queueable;
7
use Illuminate\Queue\SerializesModels;
8
use Illuminate\Support\Facades\Storage;
9
use Illuminate\Queue\InteractsWithQueue;
10
use Illuminate\Contracts\Queue\ShouldQueue;
11
use Illuminate\Foundation\Bus\Dispatchable;
12
use LWS\ExportActions\Events\QueueProcessed;
13
14
class WritePdf implements ShouldQueue
15
{
16
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
0 ignored issues
show
The trait Illuminate\Queue\SerializesModels requires some properties which are not provided by LWS\ExportActions\Jobs\WritePdf: $id, $relations, $class, $keyBy
Loading history...
17
18
    protected $html;
19
    protected $table_id;
20
21
    public $timeout = 120;
22
23
    /**
24
     * Create a new job instance.
25
     *
26
     * @return void
27
     */
28
    public function __construct($html, $table_id)
29
    {
30
        $this->html = $html;
31
        $this->table_id = $table_id;
32
    }
33
34
    /**
35
     * Execute the job.
36
     *
37
     * @return void
38
     */
39
    public function handle()
40
    {
41
        PDF::SetTitle('Export Data.');
42
        PDF::AddPage();
43
        PDF::writeHTML($this->html);
44
        $pdfString = PDF::Output('hello_world.pdf', 'S');
45
        Storage::disk('local')->put('pdf.pdf', $pdfString);
46
        event(new QueueProcessed(storage_path().'/app/pdf.pdf', $this->table_id));
47
    }
48
}
49