PHP code example of skelag / laravel-translatable-model
1. Go to this page and download the library: Download skelag/laravel-translatable-model 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/ */
skelag / laravel-translatable-model example snippets
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateBooksTable extends Migration
{
public function up()
{
Schema::create('books', function (Blueprint $table) {
$table->id();
$table->date('written_at')->default(now());
$table->timestamps();
});
$this->translates('books', ['author' => 'string', 'name' => 'string']);
}
public function down()
{
$this->dropTranslates('books');
Schema::dropIfExists('books');
}
}
namespace App\Models;
use SkelaG\LaravelTranslatableModel\Models\TranslatableModel;
class Book extends TranslatableModel
{
}
namespace App\Models;
use SkelaG\LaravelTranslatableModel\Models\TranslationModel;
class BookTranslation extends TranslationModel
{
protected array $translatable = ['name', 'author'];
}