1 | <?php |
||
11 | abstract class JsonApiController extends Controller |
||
12 | { |
||
13 | use JsonApiErrors; |
||
14 | |||
15 | /** |
||
16 | * Return the Eloquent Model for the resource. |
||
17 | * |
||
18 | * @return Model |
||
19 | */ |
||
20 | abstract protected function getModel(); |
||
21 | |||
22 | /** |
||
23 | * Return the type name of the resource. |
||
24 | * |
||
25 | * @return string |
||
26 | */ |
||
27 | protected function getModelType() |
||
31 | |||
32 | /** |
||
33 | * Return a listing of the resource. |
||
34 | * |
||
35 | * @param Request $request |
||
36 | * |
||
37 | * @return JsonApiResponse |
||
38 | */ |
||
39 | public function indexAction(Request $request) |
||
45 | |||
46 | /** |
||
47 | * Return a specified record. |
||
48 | * |
||
49 | * @param Request $request |
||
50 | * @param Model|int $record |
||
51 | * |
||
52 | * @return JsonApiResponse |
||
53 | */ |
||
54 | public function showAction(Request $request, $record) |
||
60 | |||
61 | /** |
||
62 | * Return an instance of the resource by primary key. |
||
63 | * |
||
64 | * @param mixed $key |
||
65 | * |
||
66 | * @throws \Illuminate\Database\Eloquent\ModelNotFoundException |
||
67 | * |
||
68 | * @return Model |
||
69 | */ |
||
70 | protected function findModelInstance($key) |
||
74 | |||
75 | /** |
||
76 | * Transform a set of models into a JSON API collection. |
||
77 | * |
||
78 | * @param \Illuminate\Support\Collection $records |
||
79 | * @param array $fields |
||
80 | * |
||
81 | * @return array |
||
82 | */ |
||
83 | protected function transformCollection($records, array $fields = []) |
||
93 | |||
94 | /** |
||
95 | * Transform a model instance into a JSON API object. |
||
96 | * |
||
97 | * @param Model $record |
||
98 | * @param array|null $fields Field names of attributes to limit to |
||
99 | * @param array|null $include Relations to include |
||
100 | * |
||
101 | * @return array |
||
102 | */ |
||
103 | protected function transformRecord($record, array $fields = [], array $include = []) |
||
147 | } |
||
148 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.