1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NavJobs\Transmit\Templates; |
4
|
|
|
|
5
|
|
|
use NavJobs\Transmit\Controller; |
6
|
|
|
|
7
|
|
|
class ResourceController extends Controller |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Display a listing of the resource. |
11
|
|
|
* |
12
|
|
|
* @return \Illuminate\Http\Response |
13
|
|
|
*/ |
14
|
|
|
public function index() |
15
|
|
|
{ |
16
|
|
|
return $this->respondWithPaginatedCollection(); |
17
|
|
|
} |
18
|
|
|
/** |
19
|
|
|
* Store a newly created resource in storage. |
20
|
|
|
* |
21
|
|
|
* @param \Illuminate\Http\Request $request |
|
|
|
|
22
|
|
|
* @return \Illuminate\Http\Response |
23
|
|
|
*/ |
24
|
|
|
public function store() |
25
|
|
|
{ |
26
|
|
|
$item = $this->model->create(request()->all()); |
|
|
|
|
27
|
|
|
return $this->respondWithItem($item); |
28
|
|
|
} |
29
|
|
|
/** |
30
|
|
|
* Display the specified resource. |
31
|
|
|
* |
32
|
|
|
* @param int $id |
33
|
|
|
* @return \Illuminate\Http\Response |
34
|
|
|
*/ |
35
|
|
|
public function show($id) |
36
|
|
|
{ |
37
|
|
|
return $this->respondWithItem($this->model, function ($model) use ($id) { |
38
|
|
|
return $model->findOrFail($id); |
39
|
|
|
}); |
40
|
|
|
} |
41
|
|
|
/** |
42
|
|
|
* Update the specified resource in storage. |
43
|
|
|
* |
44
|
|
|
* @param \Illuminate\Http\Request $request |
45
|
|
|
* @param int $id |
46
|
|
|
* @return \Illuminate\Http\Response |
47
|
|
|
*/ |
48
|
|
View Code Duplication |
public function update($id, Request $request) |
|
|
|
|
49
|
|
|
{ |
50
|
|
|
return $this->respondWithItem($this->model, function ($model) use ($id, $request) { |
51
|
|
|
$item = $model->findOrFail($id); |
52
|
|
|
$item->fill($request->all()); |
53
|
|
|
$item->save(); |
54
|
|
|
return $item; |
55
|
|
|
}); |
56
|
|
|
} |
57
|
|
|
/** |
58
|
|
|
* Remove the specified resource from storage. |
59
|
|
|
* |
60
|
|
|
* @param int $id |
61
|
|
|
* @return \Illuminate\Http\Response |
62
|
|
|
*/ |
63
|
|
|
public function destroy($id) |
64
|
|
|
{ |
65
|
|
|
$this->model->findOrFail($id)->delete(); |
66
|
|
|
return $this->respondWithNoContent(); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.