StoreQueuedExport.php
1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace Maatwebsite\Excel\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Maatwebsite\Excel\Files\Filesystem;
use Maatwebsite\Excel\Files\TemporaryFile;
class StoreQueuedExport implements ShouldQueue
{
use Queueable;
/**
* @var string
*/
private $filePath;
/**
* @var string|null
*/
private $disk;
/**
* @var TemporaryFile
*/
private $temporaryFile;
/**
* @var array|string
*/
private $diskOptions;
/**
* @param TemporaryFile $temporaryFile
* @param string $filePath
* @param string|null $disk
* @param array|string $diskOptions
*/
public function __construct(TemporaryFile $temporaryFile, string $filePath, string $disk = null, $diskOptions = [])
{
$this->disk = $disk;
$this->filePath = $filePath;
$this->temporaryFile = $temporaryFile;
$this->diskOptions = $diskOptions;
}
/**
* @param Filesystem $filesystem
*/
public function handle(Filesystem $filesystem)
{
$filesystem->disk($this->disk, $this->diskOptions)->copy(
$this->temporaryFile,
$this->filePath
);
$this->temporaryFile->delete();
}
}