|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace FaithGen\SDK\Observers; |
|
4
|
|
|
|
|
5
|
|
|
use FaithGen\SDK\Jobs\Users\ProcessImage; |
|
6
|
|
|
use FaithGen\SDK\Jobs\Users\S3Upload; |
|
7
|
|
|
use FaithGen\SDK\Jobs\Users\UploadImage; |
|
8
|
|
|
use FaithGen\SDK\Models\User; |
|
9
|
|
|
use FaithGen\SDK\Traits\FileTraits; |
|
10
|
|
|
use Illuminate\Support\Facades\Hash; |
|
11
|
|
|
use Illuminate\Support\Str; |
|
12
|
|
|
|
|
13
|
|
|
class UserObserver |
|
14
|
|
|
{ |
|
15
|
|
|
use FileTraits; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Handle the user "created" event. |
|
19
|
|
|
* |
|
20
|
|
|
* @param \App\User $user |
|
|
|
|
|
|
21
|
|
|
* @return void |
|
22
|
|
|
*/ |
|
23
|
|
|
public function creating(User $user) |
|
24
|
|
|
{ |
|
25
|
|
|
$user->id = (string) Str::uuid(); |
|
26
|
|
|
$user->password = Hash::make(env('DEFAULT_PASSWORD', 'secret')); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function created(User $user) |
|
30
|
|
|
{ |
|
31
|
|
|
if (request()->has('image')) { |
|
32
|
|
|
UploadImage::withChain([ |
|
33
|
|
|
new ProcessImage($user), |
|
34
|
|
|
new S3Upload($user), |
|
35
|
|
|
])->dispatch($user, request('image')); |
|
36
|
|
|
} |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Handle the user "updated" event. |
|
41
|
|
|
* |
|
42
|
|
|
* @param \App\User $user |
|
43
|
|
|
* @return void |
|
44
|
|
|
*/ |
|
45
|
|
|
public function updated(User $user) |
|
46
|
|
|
{ |
|
47
|
|
|
if (request()->has('image')) { |
|
48
|
|
|
$this->deleteFiles($user); |
|
49
|
|
|
UploadImage::withChain([ |
|
50
|
|
|
new ProcessImage($user), |
|
51
|
|
|
new S3Upload($user), |
|
52
|
|
|
])->dispatch($user, request('image')); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Handle the user "deleted" event. |
|
58
|
|
|
* |
|
59
|
|
|
* @param \App\User $user |
|
60
|
|
|
* @return void |
|
61
|
|
|
*/ |
|
62
|
|
|
public function deleted(User $user) |
|
63
|
|
|
{ |
|
64
|
|
|
if ($user->image()->exists()) { |
|
65
|
|
|
$this->deleteFiles($user); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Handle the user "restored" event. |
|
71
|
|
|
* |
|
72
|
|
|
* @param \App\User $user |
|
73
|
|
|
* @return void |
|
74
|
|
|
*/ |
|
75
|
|
|
public function restored(User $user) |
|
|
|
|
|
|
76
|
|
|
{ |
|
77
|
|
|
// |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Handle the user "force deleted" event. |
|
82
|
|
|
* |
|
83
|
|
|
* @param \App\User $user |
|
84
|
|
|
* @return void |
|
85
|
|
|
*/ |
|
86
|
|
|
public function forceDeleted(User $user) |
|
|
|
|
|
|
87
|
|
|
{ |
|
88
|
|
|
// |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths