1212use Illuminate \Database \Eloquent \Model ;
1313use Illuminate \Database \Eloquent \Relations \Relation ;
1414use Illuminate \Support \Collection ;
15- use JetBrains \PhpStorm \Internal \TentativeType ;
1615use JsonSerializable ;
1716use MyCLabs \Enum \Enum as MyclabsEnum ;
18- use Nette \Utils \Json ;
1917use Spatie \Enum \Enum as SpatieEnum ;
2018use Spatie \LaravelOptions \Providers \ArrayProvider ;
2119use Spatie \LaravelOptions \Providers \AsyncModelProvider ;
2725use Spatie \LaravelOptions \Providers \SpatieEnumProvider ;
2826use Spatie \LaravelOptions \Providers \SpatieStateProvider ;
2927use Stringable ;
30- use UnitEnum ;
3128
3229class Options implements Arrayable, Jsonable, JsonSerializable, Htmlable, Stringable
3330{
@@ -165,10 +162,10 @@ public function toArray(): array
165162 {
166163 return $ this ->provider
167164 ->provide ()
168- ->when ($ this ->filter instanceof Closure, fn (Collection $ collection ) => $ collection ->filter ($ this ->filter ))
169- ->when ($ this ->reject instanceof Closure, fn (Collection $ collection ) => $ collection ->reject ($ this ->reject ))
170- ->when ($ this ->sort instanceof Closure, fn (Collection $ collection ) => $ collection ->sortBy ($ this ->sort ))
171- ->when ($ this ->unique instanceof Closure, fn (Collection $ collection ) => $ collection ->unique ($ this ->sort ))
165+ ->when ($ this ->filter instanceof Closure, fn (Collection $ collection ) => $ collection ->filter ($ this ->filter ))
166+ ->when ($ this ->reject instanceof Closure, fn (Collection $ collection ) => $ collection ->reject ($ this ->reject ))
167+ ->when ($ this ->sort instanceof Closure, fn (Collection $ collection ) => $ collection ->sortBy ($ this ->sort ))
168+ ->when ($ this ->unique instanceof Closure, fn (Collection $ collection ) => $ collection ->unique ($ this ->sort ))
172169 ->map (function (mixed $ item ) {
173170 $ option = $ item instanceof Selectable
174171 ? $ item ->toSelectOption ()
@@ -184,17 +181,20 @@ public function toArray(): array
184181
185182 return $ option ;
186183 })
187- ->when ($ this ->unique === true , fn (Collection $ collection ) => $ collection ->unique (
188- fn (SelectOption $ option ) => $ option ->value
184+ ->when ($ this ->unique === true , fn (Collection $ collection ) => $ collection ->unique (
185+ fn (SelectOption $ option ) => $ option ->value
189186 ))
190187 ->push (...$ this ->pushedOptions )
191- ->when ($ this ->sort === true , fn (Collection $ collection ) => $ collection ->sortBy (
192- fn (SelectOption $ option ) => $ option ->label
188+ ->when ($ this ->sort === true , fn (Collection $ collection ) => $ collection ->sortBy (
189+ fn (SelectOption $ option ) => $ option ->label
193190 ))
194191 ->values ()
195- ->when ($ this ->nullable , fn (Collection $ collection ) => $ collection ->prepend (new SelectOption (
192+ ->when (
193+ $ this ->nullable ,
194+ fn (Collection $ collection ) => $ collection ->prepend (new SelectOption (
196195 $ this ->nullableLabel ,
197- null ))
196+ null
197+ ))
198198 )
199199 ->toArray ();
200200 }
@@ -207,7 +207,7 @@ public function toJson($options = 0)
207207 public function toHtml (): string
208208 {
209209 return collect ($ this ->toArray ())
210- ->map (fn (string $ label , string |int |null $ value ) => "<option value=' {$ value }'> {$ label }</option> " )
210+ ->map (fn (string $ label , string |int |null $ value ) => "<option value=' {$ value }'> {$ label }</option> " )
211211 ->join (PHP_EOL );
212212 }
213213
0 commit comments