PHP code example of lechihuy / laratrans

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

    

lechihuy / laratrans example snippets




use Laratrans\Translatable;

class Post extends Model
{
    use Translatable;
}

class Post extends Model
{
    /**
     * The columns are translatable.
     * 
     * @var string[]
    */
    public array $translatedAttributes = ['title', 'description'];
    
    /**
     * The relationships that should always be loaded.
     *
     * @var array
     */
    protected $with = ['translations'];
}

class Post extends Model
{
    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = ['post_id'];
}
shell
php artisan laratrans:install
shell
php artisan make:model Translation/PostTranslation