1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace FaithGen\SDK\Observers; |
4
|
|
|
|
5
|
|
|
use FaithGen\SDK\Models\Ministry; |
6
|
|
|
use FaithGen\SDK\Notifications\Ministry\AccountCreated; |
7
|
|
|
use FaithGen\SDK\Traits\FileTraits; |
8
|
|
|
use Illuminate\Support\Facades\Hash; |
9
|
|
|
use Illuminate\Support\Str; |
10
|
|
|
|
11
|
|
|
class MinistryObserver |
12
|
|
|
{ |
13
|
|
|
use FileTraits; |
14
|
|
|
|
15
|
|
|
public function creating(Ministry $ministry) |
16
|
|
|
{ |
17
|
|
|
$ministry->password = Hash::make(request()->password); |
18
|
|
|
$ministry->id = (string) Str::uuid(); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Handle the ministry "created" event. |
23
|
|
|
* |
24
|
|
|
* @param \App\Models\Ministry $ministry |
|
|
|
|
25
|
|
|
* |
26
|
|
|
* @throws \Exception |
27
|
|
|
* @return void |
28
|
|
|
*/ |
29
|
|
|
public function created(Ministry $ministry) |
30
|
|
|
{ |
31
|
|
|
$ministry->profile()->save(new Ministry\Profile()); |
32
|
|
|
$ministry->account()->save(new Ministry\Account()); |
33
|
|
|
$ministry->activation()->save(new Ministry\Activation()); |
34
|
|
|
$ministry->apiKey()->save(new Ministry\APIKey([ |
35
|
|
|
'api_key' => str_shuffle(Str::uuid()->toString()), |
36
|
|
|
])); |
37
|
|
|
|
38
|
|
|
$ministry->notify(new AccountCreated($ministry)); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Handle the ministry "updated" event. |
43
|
|
|
* |
44
|
|
|
* @param Ministry $ministry |
45
|
|
|
* |
46
|
|
|
* @return void |
47
|
|
|
*/ |
48
|
|
|
public function updated(Ministry $ministry) |
49
|
|
|
{ |
50
|
|
|
if (request()->has('services')) { |
51
|
|
|
$ministry->services()->insert(request()->services); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Handle the ministry "deleted" event. |
57
|
|
|
* |
58
|
|
|
* @param Ministry $ministry |
59
|
|
|
* |
60
|
|
|
* @return void |
61
|
|
|
*/ |
62
|
|
|
public function deleted(Ministry $ministry) |
63
|
|
|
{ |
64
|
|
|
//todo remove aa lotta staff related to this ministry |
65
|
|
|
if ($ministry->image()->exists()) { |
66
|
|
|
$ministry->image()->delete(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
try { |
70
|
|
|
$this->deleteFiles($ministry); |
71
|
|
|
} catch (\Exception $e) { |
|
|
|
|
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
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