PHP code example of cosnavel / laravel-query-localization

1. Go to this page and download the library: Download cosnavel/laravel-query-localization library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cosnavel / laravel-query-localization example snippets


// routes/web.php


Route::middleware(LocaleFromQuery::class)->group(function () {
    Route::view('/', 'welcome');
});

Cosnavel\LaravelQueryLocalization\Facades\LaravelQueryLocalization::getSupportedLocales();

Cosnavel\LaravelQueryLocalization\Facades\LaravelQueryLocalization::getCurrentLocale();

Cosnavel\LaravelQueryLocalization\Facades\LaravelQueryLocalization::determineValidLanguage('en');

Cosnavel\LaravelQueryLocalization\Facades\LaravelQueryLocalization::setLocale('en');

Cosnavel\LaravelQueryLocalization\Facades\LaravelQueryLocalization::setUserLanguagePreference('en');
bash
php artisan vendor:publish --provider="Cosnavel\LaravelQueryLocalization\LaravelQueryLocalizationServiceProvider" --tag="laravel-query-localization-config"
bash
php artisan vendor:publish --provider="Cosnavel\LaravelQueryLocalization\LaravelQueryLocalizationServiceProvider" --tag="query-localization-migrations"
php artisan migrate
bash

php artisan vendor:publish --provider="Cosnavel\LaravelQueryLocalization\LaravelQueryLocalizationServiceProvider" --tag="query-localization-views"