|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ikechukwukalu\Clamavfileupload\Trait; |
|
4
|
|
|
|
|
5
|
|
|
use Ikechukwukalu\Clamavfileupload\Events\QueuedDeleteAll; |
|
6
|
|
|
use Ikechukwukalu\Clamavfileupload\Events\QueuedDeleteMultiple; |
|
7
|
|
|
use Ikechukwukalu\Clamavfileupload\Events\QueuedDeleteOne; |
|
8
|
|
|
use Ikechukwukalu\Clamavfileupload\Events\QueuedForceDeleteAll; |
|
9
|
|
|
use Ikechukwukalu\Clamavfileupload\Events\QueuedForceDeleteMultiple; |
|
10
|
|
|
use Ikechukwukalu\Clamavfileupload\Events\QueuedForceDeleteOne; |
|
11
|
|
|
|
|
12
|
|
|
trait QueuedDelete { |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Soft delete all files from database by ref. |
|
16
|
|
|
* |
|
17
|
|
|
* @param string $ref |
|
18
|
|
|
* @return bool |
|
19
|
|
|
*/ |
|
20
|
|
|
public function deleteAll(string $ref): bool |
|
21
|
|
|
{ |
|
22
|
|
|
QueuedDeleteAll::dispatch($ref); |
|
23
|
|
|
return true; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Soft delete multiple files from database by ref and Ids. |
|
28
|
|
|
* |
|
29
|
|
|
* @param string $ref |
|
30
|
|
|
* @param array $ids |
|
31
|
|
|
* @return bool |
|
32
|
|
|
*/ |
|
33
|
|
|
public function deleteMultiple(array $ids, null|string $ref = null): bool |
|
34
|
|
|
{ |
|
35
|
|
|
QueuedDeleteMultiple::dispatch($ids, $ref); |
|
36
|
|
|
return true; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Soft delete single file from database by ref and id. |
|
41
|
|
|
* |
|
42
|
|
|
* @param string $ref |
|
43
|
|
|
* @param int|string $id |
|
44
|
|
|
* @return bool |
|
45
|
|
|
*/ |
|
46
|
|
|
public function deleteOne(int|string $id, null|string $ref = null): bool |
|
47
|
|
|
{ |
|
48
|
|
|
QueuedDeleteOne::dispatch($id, $ref); |
|
49
|
|
|
return true; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Permanently delete all files from directory and database by ref. |
|
54
|
|
|
* |
|
55
|
|
|
* @param string $ref |
|
56
|
|
|
* @return bool |
|
57
|
|
|
*/ |
|
58
|
|
|
public function forceDeleteAll(string $ref): bool |
|
59
|
|
|
{ |
|
60
|
|
|
QueuedForceDeleteAll::dispatch($ref); |
|
61
|
|
|
return true; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Permanently delete multiple files from directory |
|
66
|
|
|
* and database by ref and Ids. |
|
67
|
|
|
* |
|
68
|
|
|
* @param string $ref |
|
69
|
|
|
* @param array $ids |
|
70
|
|
|
* @return bool |
|
71
|
|
|
*/ |
|
72
|
|
|
public function forceDeleteMultiple(array $ids, null|string $ref = null): bool |
|
73
|
|
|
{ |
|
74
|
|
|
QueuedForceDeleteMultiple::dispatch($ids, $ref); |
|
75
|
|
|
return true; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Permanently delete single file from directory |
|
80
|
|
|
* and database by ref and id. |
|
81
|
|
|
* |
|
82
|
|
|
* @param string $ref |
|
83
|
|
|
* @param int|string $id |
|
84
|
|
|
* @return bool |
|
85
|
|
|
*/ |
|
86
|
|
|
public function forceDeleteOne(int|string $id, null|string $ref = null): bool |
|
87
|
|
|
{ |
|
88
|
|
|
QueuedForceDeleteOne::dispatch($id, $ref); |
|
89
|
|
|
return true; |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|