PHP code example of mihkullorg / laravel-translatable

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

    

mihkullorg / laravel-translatable example snippets

 artisan vendor:publish --tag=translatable

use Mihkullorg\Translatable\Traits\Translatable;

class Post extends Model 
{
    use Translatable;
    
    public $fillable = ['body'];
}

$post->translations();
$post->translation($field, $language, $createIfNotFresh = false);

$post->freshTranslation($field, $language);

$post->translate('body', 'en', 'New translated body');

$translation = $post->translate('body', 'en');