Rhincodon / laravel-db-language by Rhincodon

Laravel 5.1 Database Language
207
1
2
Package Data
Maintainer Username: Rhincodon
Maintainer Contact: rhinodontypicus@gmail.com (rhinodontypicus)
Package Create Date: 2015-06-13
Package Last Update: 2016-03-19
Language: PHP
License: MIT
Last Refreshed: 2024-12-19 03:12:40
Package Statistics
Total Downloads: 207
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 1
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

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.