PHP code example of jvdlaar / laravel-content-translation
1. Go to this page and download the library: Download jvdlaar/laravel-content-translation 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/ */
jvdlaar / laravel-content-translation example snippets
namespace App\Models;
use App\Base\Model;
use App\Contracts\TranslatableContract;
use App\Models\Traits\HasTranslatables;
class Country extends Model implements TranslatableContract {
use HasTranslatables;
protected $table = 'countries';
protected $fillable = ['code', 'admin_name'];
public $timestamps = FALSE;
public $users = FALSE;
/**
* ATTRIBUTES
*/
/**
* Getter for 'name'.
*/
public function getNameAttribute() {
return $this->displayTranslation('name', TRUE);
}
/**
* Getter for 'nationality'.
*/
public function getNationalityAttribute() {
return $this->displayTranslation('nationality', TRUE);
}
/**
* Return an default for a property in this content.
*/
protected function getTranslationDefault($property) {
return $this->admin_name;
}
}