PHP code example of wecansync / laravel-translations

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

    

wecansync / laravel-translations example snippets


    namespace App\Models;
    
    use Illuminate\Database\Eloquent\Model;
    use WeCanSync\LaravelTranslations\Traits\HasTranslations;
    
    class ModelName extends Model
    {
       use HasTranslations;
   
       protected $translation_model = [
            'model' => TranslationsModelName::class,
            'translatable' => ['name'],
        //  'foreign_key' => 'language_id', 
        //  'owner_key' => 'model_name_id',
       
        //  by default the foreign key name is "language_id"
        //  and the owner_key name is model_id
       
        //  if you would like to replace it for all models
        //  you can change it in config/laravel-translations
       
    
        ]; 
    
bash
php artisan vendor:publish --provider="WeCanSync\LaravelTranslations\PackageServiceProvider"