| 1 | <?php | ||
| 8 | trait Loadmore | ||
| 9 | { | ||
| 10 | /** | ||
| 11 | * Prepare a loadmore pagination. | ||
| 12 | * | ||
| 13 | * @param integer $initial | ||
| 14 | * @param integer $loadMore | ||
| 15 | * @return \Illuminate\Pagination\LengthAwarePaginator | ||
| 16 | */ | ||
| 17 | public function loadmore($initial = 4, $loadMore = 16) | ||
| 33 | |||
| 34 | /** | ||
| 35 | * Scope a query to match loadmore style. | ||
| 36 | * | ||
| 37 | * @param \Illuminate\Database\Eloquent\Builder $query | ||
| 38 | * @param integer $initial | ||
| 39 | * @param integer $loadMore | ||
| 40 | * @return \Illuminate\Database\Eloquent\Builder | ||
| 41 | */ | ||
| 42 | public function scopeLoadmore($query, $initial = 4, $loadMore = 16) | ||
| 46 | } | ||
| 47 | 
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
Idableprovides a methodequalsIdthat 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.