Skip to content

It is a standard package for managing different system languages in Laravel.

License

Notifications You must be signed in to change notification settings

jobmetric/laravel-language

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers MIT License LinkedIn

Language for laravel

It is a standard package for managing different system languages in Laravel.

Install via composer

Run the following command to pull in the latest version:

composer require jobmetric/laravel-language

Documentation

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.

Before doing anything, you must migrate after installing the package by composer.

php artisan migrate

Usage

Store language

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
]);

Update language

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
]);

Delete language

You can delete an existing language by using the following code:

use JobMetric\Language\Facades\Language

$language = Language::delete($language->id);

Get all languages

You can get all languages by using the following code:

use JobMetric\Language\Facades\Language

$languages = Language::all();

Get language by id

You can get a language by id by using the following code:

use JobMetric\Language\Facades\Language

$language = Language::all([
    'id' => $language->id
]);

Get language by locale

You can get a language by locale by using the following code:

use JobMetric\Language\Facades\Language

$language = Language::all([
    'locale' => 'en'
]);

Rules

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.

Events

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.

Contributing

Thank you for considering contributing to the Laravel Language! The contribution guide can be found in the CONTRIBUTING.md.

License

The MIT License (MIT). Please see License File for more information.