PHP code example of said / private-package
1. Go to this page and download the library: Download said/private-package 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/ */
said / private-package example snippets
namespace App;
use Illuminate\Database\Eloquent\Model;
use Said\Translatable\Traits\Translatable;
class MyModel extends Model
{
use Translatable;
protected $translatable_columns=[
'name'
];
protected $fillable=[
'price'
];
}
// assuming $myModel is an instace of MyModel class defined above
// and the translations are set
echo $myModel->name; // returns 'Product'
App::setLocale('fr');
echo $myModel->name; // returns 'Produit'
$myModel->in('fr')->translate('name'); // returns 'Produit'