rhincodon / laravel-db-language
Laravel 5.1 Database Language
1.0.4
2016-03-19 22:47 UTC
Requires
- php: >=5.5.9
- illuminate/database: ~5.1
- illuminate/support: ~5.1
Requires (Dev)
- orchestra/testbench: ^3.0
- phpunit/phpunit: 4.*
- scrutinizer/ocular: ~1.1
This package is not auto-updated.
Last update: 2024-11-20 16:59:42 UTC
README
Install
Via Composer
$ composer require rhincodon/laravel-db-language
Usage
Register Service Provider in config/app.php
:
Rhinodontypicus\DBLanguage\DbLanguageServiceProvider::class,
Publish config and migration and migrate:
php artisan vendor:publish php artisan migrate
Package have 3 models — Language, Value, Constant. You can extend them and use in your app to create language/value/constant.
For usage you need to create one Language in your database. Then you can load all constants/values in your middleware for language and use them like so:
$language = \Rhinodontypicus\DBLanguage\Language::create(['name' => 'English']); // Create language // Somewhere in your middleware you can load all constants db_language()->load($language->id); // Load all constants for language db_language()->load($language->id, 'site'); // Load all constants for language from 'site' group // Somewhere in view/controller, group::value syntax db_language('site::some_constant'); // Get language constant for loaded language db_language('site::some_constant', 'Default Value'); // Get language constant with default value. If constant does not exists, value will be created in database for the first time db_language()->language(); // Get current loaded language db_language()->language('name'); // Current loaded language field
Credits
License
The MIT License (MIT). Please see License File for more information.