PHP code example of bramalho / laravel-translations
1. Go to this page and download the library: Download bramalho/laravel-translations 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/ */
namespace App;
use Illuminate\Database\Eloquent\Model;
use BRamalho\LaravelTranslations\Translate;
class Page extends Model
{
use Translate;
protected $fillable = ['title', 'body'];
}
use Illuminate\Database\Seeder;
use App\Page;
use BRamalho\LaravelTranslations\Translation;
class PageTableSeeder extends Seeder
{
public function run()
{
Page::create([
'id' => 1,
'title' => 'Hello World!',
'body' => 'This is my page'
]);
Translation::create([
'id' => 1,
'translation_id' => 1,
'translation_type' => App\Page::class,
'language' => 'pt',
'content' => [
'title' => 'Olá Mundo!',
'body' => 'Esta é a minha página'
]
]);
}
}
sh
php artisan vendor:publish --provider 'BRamalho\LaravelTranslations\LaravelTranslationsServiceProvider'