PHP code example of dongrim / laravel-localization

1. Go to this page and download the library: Download dongrim/laravel-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/ */

    

dongrim / laravel-localization example snippets


 namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel {
    /**
    * The application's route middleware.
    *
    * @var array
    */
    protected $routeMiddleware = [
        /**** OTHER MIDDLEWARE ****/
        'localize' => \Dongrim\LaravelLocalization\Middleware\LocalizationMiddleware::class,
    ];
}

// routes/web.php

Route::group([
    'prefix' => Localization::prefix(),
    'middleware'=>['localize']
], function(){
	/** ADD ALL LOCALIZED ROUTES INSIDE THIS GROUP **/
	Route::get('/', function(){
		return View::make('welcome');
	})->name('welcome');

    Route::get('test',function(){
		return View::make('test');
	})->name('test');
});

/** OTHER PAGES THAT SHOULD NOT BE LOCALIZED **/



namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Dongrim\LaravelLocalization\Traits\Localizable;
use Dongrim\LaravelLocalization\Contracts\Localization as LocalizationContract;

class Localization extends Model implements LocalizationContract
{
    use Localizable;
}


php artisan vendor:publish --provider="Dongrim\LaravelLocalization\LaravelLocalizationServiceProvider"
 bash
php artisan route:clear