| 1 | <?php |
||
| 13 | trait FieldHandleUpload |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | protected $disk = 'public'; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | protected $path = 'uploads'; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var string |
||
| 27 | */ |
||
| 28 | protected $mimes; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @var int |
||
| 32 | */ |
||
| 33 | protected $max_size; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @param string $disk |
||
| 37 | * @return self |
||
| 38 | */ |
||
| 39 | public function uploadToDisk($disk = 'public') |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @param string $path |
||
| 48 | * @return self |
||
| 49 | */ |
||
| 50 | public function uploadToPath($path = 'uploads') |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @param string $types |
||
| 59 | * @return self |
||
| 60 | */ |
||
| 61 | public function withTypes($types) |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @param int $size |
||
| 70 | * @return self |
||
| 71 | */ |
||
| 72 | public function withMaxSize($size = 2048) |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @param Validator $validator |
||
| 81 | * @return Validator |
||
| 82 | */ |
||
| 83 | public function beforeValidation(Validator $validator) |
||
| 108 | } |
||
| 109 |
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.