artem-alekseev / dictionaries
Use dictionary in laravel
Installs: 560
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/artem-alekseev/dictionaries
Requires
- php: ^7.0|^8.0
- laravel/framework: ^8.0
README
Composer
How install package
composer require artem-alekseev/dictionaries:1.*
Usage
Make Dictionary
Use laravel artisan command
php artisan make:dictionary NameDictionary
In dictionary
class NameDictionary extends Dictionary { const ONE = 1; const TWO = 2; public static function getDictionary(): array { return [ self::ONE => 'One', self::TWO => 'Two', ]; } }
Use in code
echo NameDictionary::ONE; // out 1 echo NameDictionary::getValueData($this->id); // id = 2 // out 'Two' echo NameDictionary::getRange(); // out [1,2] use in validation echo NameDictionary::getStringRange(); // out '1,2' use in validation echo NameDictionary::getDictionary() // out [1 => 'One', 2 => 'Two'] use in selector form field
License
This project is licensed under the MIT License - see the LICENSE.md file for details