PHP code example of gertjanroke / translations

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

    

gertjanroke / translations example snippets


'providers' => [
	...
	Gertjanroke\Notification\NotificationServiceProvider::class,
	...
],

class Page extends Model
{
	...
	use Translations;
	...
}

...
use Gertjanroke\Translations\Traits\Translations;

class Page extends Model
{
	...

class PageTranslations extends Model
{
    //
}

public function store(Request $request)
{
	...
	$page = new Page();
	$page->saveTranslations($request);
	...
}

public function store(Request $request)
{
	...
	$page = new Page();
	$page->saveTrans($request);
	...
}

$page->title

$page->getTitle();

$page->getTitle('en');

...
use Gertjanroke\Translations\Traits\Translations;

class Page extends Model
{
	...
	use Translations;

    protected $transForeignKey = 'pages_id';
    ...
}
bash
php artisan vendor:publish --provider="Gertjanroke\Notification\NotificationServiceProvider"