PHP code example of chrisabey84 / laravel-cached-options-list

1. Go to this page and download the library: Download chrisabey84/laravel-cached-options-list library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

chrisabey84 / laravel-cached-options-list example snippets


return [
    'key' => 'id', //The index/key column for the select options array
    'value' => 'name', //The value column for the select options array
];

$rows = \App\Models\MyModel::asSelectArray();

<select name="mySelectBox">
@foreach($rows as $key => $value)
	<option value="{{ $key }}">{{ $value }}</option>
@endforeach
</select>

protected static function buildQuery(): Builder
{
	return static::query();
}

\App\Models\MyModel::clearOptionsCache();
bash
php artisan vendor:publish --provider="Chrisabey84\LaravelCachedOptionsList\LaravelCachedOptionsListServiceProvider
bash
php artisan cached-options:clear '\App\Models\MyModel'