It is a standard package for managing different system languages in Laravel.
Run the following command to pull in the latest version:
composer require jobmetric/laravel-language
This package evolves every day under continuous development and integrates a diverse set of features. It's a must-have asset for Laravel enthusiasts and provides a seamless way to align your projects with basic language models.
To use the services of this package, please follow the instructions below.
php artisan migrate
You can store a new language by using the following code:
use JobMetric\Language\Facades\Language
$language = Language::store([
'name' => 'English',
'flag' => 'us',
'locale' => 'en',
'direction' => 'ltr',
'status' => true
]);
You can update an existing language by using the following code:
use JobMetric\Language\Facades\Language
$language = Language::update($language->id, [
'name' => 'English',
'flag' => 'us',
'locale' => 'en',
'direction' => 'ltr',
'status' => true
]);
You can delete an existing language by using the following code:
use JobMetric\Language\Facades\Language
$language = Language::delete($language->id);
You can get all languages by using the following code:
use JobMetric\Language\Facades\Language
$languages = Language::all();
You can get a language by id by using the following code:
use JobMetric\Language\Facades\Language
$language = Language::all([
'id' => $language->id
]);
You can get a language by locale by using the following code:
use JobMetric\Language\Facades\Language
$language = Language::all([
'locale' => 'en'
]);
This package contains several rules for which you can write a listener as follows
CheckLocaleRule
- This rule checks if the locale exists in the language table.
use JobMetric\Language\Rules\CheckLocaleRule;
$request->validate([
'locale' => ['required', new CheckLocaleRule]
]);
LanguageExistsRule
- This rule checks if the language exists in the language table.
This package contains several events for which you can write a listener as follows
Event | Description |
---|---|
LanguageStoredEvent |
This event is called after storing the language. |
LanguageUpdateEvent |
This event is called after updating the language. |
LanguageDeleteEvent |
This event is called after delete the language. |
Thank you for considering contributing to the Laravel Language! The contribution guide can be found in the CONTRIBUTING.md.
The MIT License (MIT). Please see License File for more information.