1 | <?php |
||
12 | trait JsonApiControllerActions |
||
13 | { |
||
14 | /** |
||
15 | * Return a listing of the resource. |
||
16 | * |
||
17 | * @param Request $request |
||
18 | * |
||
19 | * @return \Huntie\JsonApi\Http\JsonApiResponse |
||
20 | */ |
||
21 | public function index(Request $request) |
||
25 | |||
26 | /** |
||
27 | * Store a new record. |
||
28 | * |
||
29 | * @param Request $request |
||
30 | * |
||
31 | * @return \Huntie\JsonApi\Http\JsonApiResponse |
||
32 | */ |
||
33 | public function store(Request $request) |
||
37 | |||
38 | /** |
||
39 | * Return a specified record. |
||
40 | * |
||
41 | * @param Request $request |
||
42 | * @param int $id |
||
43 | * |
||
44 | * @return \Huntie\JsonApi\Http\JsonApiResponse |
||
45 | */ |
||
46 | public function show(Request $request, $id) |
||
50 | |||
51 | /** |
||
52 | * Update a specified record. |
||
53 | * |
||
54 | * @param Request $request |
||
55 | * @param int $id |
||
56 | * |
||
57 | * @return \Huntie\JsonApi\Http\JsonApiResponse |
||
58 | */ |
||
59 | public function update(Request $request, $id) |
||
63 | |||
64 | /** |
||
65 | * Destroy a specified record. |
||
66 | * |
||
67 | * @param Request $request |
||
68 | * @param int $id |
||
69 | * |
||
70 | * @return \Huntie\JsonApi\Http\JsonApiResponse |
||
71 | */ |
||
72 | public function destroy(Request $request, $id) |
||
76 | |||
77 | /** |
||
78 | * Return a specified record relationship. |
||
79 | * |
||
80 | * @param Request $request |
||
81 | * @param int $id |
||
82 | * @param string $relation |
||
83 | * |
||
84 | * @return \Huntie\JsonApi\Http\JsonApiResponse |
||
85 | */ |
||
86 | public function showRelationship(Request $request, $id, $relation) |
||
90 | } |
||
91 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.