1 | <?php |
||
5 | trait HasRank |
||
6 | { |
||
7 | public function rankUp() |
||
11 | |||
12 | public function rankDown() |
||
16 | |||
17 | public function makeFirst() |
||
21 | |||
22 | public function makeLast() |
||
26 | |||
27 | public function getFirstRank($query = false) |
||
34 | |||
35 | public function getLastRank($query = false) |
||
42 | |||
43 | public function swapRank($swapper) |
||
58 | |||
59 | /** |
||
60 | * Set rank to model. |
||
61 | * |
||
62 | * @param $rank |
||
63 | * @return $this |
||
64 | */ |
||
65 | public function setRank($rank) |
||
73 | |||
74 | public function getRankIndex() |
||
78 | |||
79 | public function getRank() |
||
83 | |||
84 | public function rank() |
||
88 | |||
89 | public function scopeRanked($query, $order = 'DESC') |
||
93 | |||
94 | public function scopeFindRank($query, $rank) |
||
98 | } |
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.