Skip to content

Commit

Permalink
Completed support for non-object array collections
Browse files Browse the repository at this point in the history
  • Loading branch information
ringunger committed Nov 19, 2024
1 parent 09a2251 commit e115536
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ other than '`active`', and a custom class '`form-option custom`' will be applied
> <small><strong>Note:</strong> Writing queries within blade templates is not recommended. This is only for simplifying
> demonstration</small>
### Non-object Array Collections
You can work with collections of non-object arrays both flat and associative
```php
$array1 = ["First", "Second", "Third"];
$array2 = ['first' => "First", 'second' => "Second", 'third' => "Third"];
$array3 = [['name' => 'First', 'number' => 1],['name' => 'Second', 'number' => 2],['name' => 'Third', 'number' => 3]]
$options = collect($array)->toSelectOptions();
$options2 = collect($array2)->toSelectOptions();
$options3 = collect($array3)->toSelectable()->withValue('number')->toSelectOptions();
```


## Get Selectable Items
```php
$selectableItems = \App\Models\User::all()->toSelectable()->toSelectItems();
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"name": "master"
}
},
"version": "1.0.2",
"version": "1.0.3",
"minimum-stability": "dev",
"prefer-stable": true
}

0 comments on commit e115536

Please sign in to comment.