==================================================
//Post Model
<?php
namespace App\Models;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Eloquent\Model;
use Astrotomic\Translatable\Translatable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
// use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract;
class Post extends Model implements TranslatableContract
{
use HasFactory, Translatable;
public function __construct(array $attributes = [])
{
$this->fillable = Schema::getColumnListing($this->getTable());
parent::__construct($attributes);
}
// protected $guarded = ['id'];
public $translatedAttributes = ['title', 'full_text'];
}
==============================================
//PostTranslation Model
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class PostTranslation extends Model
{
use HasFactory;
public $timestamps = false;
protected $fillable = ['author','title', 'full_text'];
}
public function store(Request $request)
{
$request->request->add(['author'=> auth()->user()->name]);
$request->request->add(['is_active'=> 1]);
Post::create($request->validated());
return redirect()->route('dashboard');
}
=============================================
when submit the form it save only ('title','content') to table post_translations only.
so what problem with it?
Dear Developer! I have some problem with this package like below:
================================================== //Post Model
============================================== //PostTranslation Model
=========================================== //Controller
============================================= when submit the form it save only ('title','content') to table post_translations only. so what problem with it?