|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Modules\Application\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use Foundation\Abstracts\Controller\Controller; |
|
6
|
|
|
use Foundation\Responses\ApiResponse; |
|
7
|
|
|
use Illuminate\Http\Request; |
|
8
|
|
|
use Modules\Application\Contracts\ApplicationServiceContract; |
|
9
|
|
|
use Modules\Application\Transformers\ApplicationTransformer; |
|
10
|
|
|
|
|
11
|
|
|
class ApplicationController extends Controller |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @var ApplicationServiceContract |
|
15
|
|
|
*/ |
|
16
|
|
|
protected $service; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* ApplicationController constructor. |
|
20
|
|
|
* |
|
21
|
|
|
* @param $service |
|
22
|
|
|
*/ |
|
23
|
|
|
public function __construct(ApplicationServiceContract $service) |
|
24
|
|
|
{ |
|
25
|
|
|
$this->service = $service; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Display a listing of the resource. |
|
30
|
|
|
*/ |
|
31
|
|
|
public function index() |
|
32
|
|
|
{ |
|
33
|
|
|
return ApplicationTransformer::collection($this->service->getByUserId(get_authenticated_user_id())); |
|
|
|
|
|
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Store a newly created Application in storage. |
|
38
|
|
|
*/ |
|
39
|
|
|
public function store(Request $request) |
|
40
|
|
|
{ |
|
41
|
|
|
$Application = $this->service->create($this->injectUserId($request)); |
|
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
return ApplicationTransformer::resource($Application); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Update a Application. |
|
48
|
|
|
* |
|
49
|
|
|
* @param Request $request |
|
50
|
|
|
*/ |
|
51
|
|
|
public function update(Request $request, $id) |
|
52
|
|
|
{ |
|
53
|
|
|
$Application = $this->service->find($id); |
|
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
$this->exists($Application); |
|
56
|
|
|
$this->hasAccess($Application); |
|
57
|
|
|
$Application = $this->service->update($id, $request->toArray()); |
|
|
|
|
|
|
58
|
|
|
|
|
59
|
|
|
return ApplicationTransformer::resource($Application); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Show the specified resource. |
|
64
|
|
|
*/ |
|
65
|
|
|
public function show($id) |
|
66
|
|
|
{ |
|
67
|
|
|
$Application = $this->service->find($id); |
|
68
|
|
|
|
|
69
|
|
|
$this->exists($Application); |
|
70
|
|
|
$this->hasAccess($Application); |
|
71
|
|
|
|
|
72
|
|
|
return ApplicationTransformer::resource($Application); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Remove the specified resource from storage. |
|
77
|
|
|
*/ |
|
78
|
|
|
public function destroy($id) |
|
79
|
|
|
{ |
|
80
|
|
|
$Application = $this->service->find($id); |
|
81
|
|
|
|
|
82
|
|
|
$this->exists($Application); |
|
83
|
|
|
$this->hasAccess($Application); |
|
84
|
|
|
|
|
85
|
|
|
$this->service->delete($Application); |
|
|
|
|
|
|
86
|
|
|
|
|
87
|
|
|
return ApiResponse::deleted(); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.