|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use App\Http\Requests\ContactStoreRequest; |
|
|
|
|
|
|
6
|
|
|
use App\Http\Resources\ContactResource; |
|
7
|
|
|
use App\Interfaces\ContactServiceInterface; |
|
8
|
|
|
use App\Interfaces\UserServiceInterface; |
|
9
|
|
|
use Illuminate\Support\Facades\Auth; |
|
10
|
|
|
|
|
11
|
|
|
class ContactController extends Controller |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @var ContactServiceInterface |
|
15
|
|
|
*/ |
|
16
|
|
|
private ContactServiceInterface $service; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var UserServiceInterface |
|
20
|
|
|
*/ |
|
21
|
|
|
private UserServiceInterface $userService; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* ContactController constructor. |
|
25
|
|
|
* |
|
26
|
|
|
* @param ContactServiceInterface $service |
|
27
|
|
|
* @param UserServiceInterface $userService |
|
28
|
|
|
*/ |
|
29
|
3 |
|
public function __construct(ContactServiceInterface $service, UserServiceInterface $userService) |
|
30
|
|
|
{ |
|
31
|
3 |
|
$this->service = $service; |
|
32
|
3 |
|
$this->userService = $userService; |
|
33
|
3 |
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Returns user by id. |
|
37
|
|
|
* |
|
38
|
|
|
* @param string $id |
|
39
|
|
|
* @return ContactResource |
|
40
|
|
|
*/ |
|
41
|
1 |
|
public function show(string $id) |
|
42
|
|
|
{ |
|
43
|
1 |
|
return new ContactResource( |
|
44
|
1 |
|
$this->service->contact($id) |
|
45
|
|
|
); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Returns contacts by user. |
|
50
|
|
|
* |
|
51
|
|
|
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection |
|
52
|
|
|
*/ |
|
53
|
1 |
|
public function index() |
|
54
|
|
|
{ |
|
55
|
1 |
|
$user = Auth::user(); |
|
56
|
|
|
|
|
57
|
1 |
|
return ContactResource::collection($this->service->contacts($user)); |
|
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Store a contact. |
|
62
|
|
|
* |
|
63
|
|
|
* @param string $user_id |
|
64
|
|
|
* @return ContactResource |
|
65
|
|
|
*/ |
|
66
|
1 |
|
public function store(string $user_id): ContactResource |
|
67
|
|
|
{ |
|
68
|
1 |
|
$user = Auth::user(); |
|
69
|
1 |
|
$contact = $this->userService->find($user_id); |
|
70
|
|
|
|
|
71
|
1 |
|
return new ContactResource( |
|
72
|
1 |
|
$this->service->addContact($user, $contact) |
|
|
|
|
|
|
73
|
|
|
); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
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