1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace App\Http\Controllers\Api\User; |
6
|
|
|
|
7
|
|
|
use App\Http\Requests\Api\User\StoreRequest; |
8
|
|
|
use App\Http\Resources\Api\UserResource; |
9
|
|
|
use App\Models\User; |
10
|
|
|
use App\Notifications\User\Invitation; |
11
|
|
|
use Illuminate\Auth\Passwords\PasswordBrokerManager; |
|
|
|
|
12
|
|
|
use Illuminate\Contracts\Auth\PasswordBroker; |
|
|
|
|
13
|
|
|
use Illuminate\Contracts\Notifications\Dispatcher; |
|
|
|
|
14
|
|
|
use Illuminate\Support\Arr; |
|
|
|
|
15
|
|
|
use Illuminate\Support\Str; |
|
|
|
|
16
|
|
|
|
17
|
|
|
final class Store |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var \Illuminate\Contracts\Notifications\Dispatcher |
21
|
|
|
*/ |
22
|
|
|
protected $notificationDispatcher; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var \Illuminate\Auth\Passwords\PasswordBrokerManager |
26
|
|
|
*/ |
27
|
|
|
protected $passwordBrokerManager; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Store constructor. |
31
|
|
|
* |
32
|
|
|
* @param \Illuminate\Contracts\Notifications\Dispatcher $notificationDispatcher |
33
|
|
|
* @param \Illuminate\Auth\Passwords\PasswordBrokerManager $passwordBrokerManager |
34
|
|
|
*/ |
35
|
|
|
public function __construct(Dispatcher $notificationDispatcher, PasswordBrokerManager $passwordBrokerManager) |
36
|
|
|
{ |
37
|
|
|
$this->notificationDispatcher = $notificationDispatcher; |
38
|
|
|
$this->passwordBrokerManager = $passwordBrokerManager; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param \App\Http\Requests\Api\User\StoreRequest $request |
43
|
|
|
* @return \App\Http\Resources\Api\UserResource |
44
|
|
|
*/ |
45
|
|
|
public function __invoke(StoreRequest $request) |
46
|
|
|
{ |
47
|
|
|
$attributes = $request->validated(); |
48
|
|
|
|
49
|
|
|
// Don't need an actual password yet as we're going to send an invite. |
50
|
|
|
Arr::set($attributes, 'password', Str::random(64)); |
51
|
|
|
|
52
|
|
|
/** @var User $user */ |
53
|
|
|
$user = User::query()->create($attributes); |
54
|
|
|
|
55
|
|
|
$this->notificationDispatcher->send($user, |
56
|
|
|
new Invitation($this->getPasswordBroker()->createToken($user)) |
57
|
|
|
); |
58
|
|
|
|
59
|
|
|
return new UserResource($user); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return \Illuminate\Contracts\Auth\PasswordBroker|\Illuminate\Auth\Passwords\PasswordBroker |
|
|
|
|
64
|
|
|
*/ |
65
|
|
|
protected function getPasswordBroker(): PasswordBroker |
66
|
|
|
{ |
67
|
|
|
return $this->passwordBrokerManager->broker('user-invitations'); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
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