Skip to content

Rhincodon/laravel-db-language

Repository files navigation

Laravel DB Language

Latest Version Software License Build Status Total Downloads

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.

About

Laravel 5.1 Database Language

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages