PHP code example of mountainclans / livewire-translatable
1. Go to this page and download the library: Download mountainclans/livewire-translatable 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/ */
mountainclans / livewire-translatable example snippets
# Your livewire component
//...
use MountainClans\LivewireTranslatable\Traits\FilledTranslatableFields;
public function mount(?string $blogId = null): void
{
if ($this->blogId) {
$this->blog = Blog::findOrFail($this->blogId);
$this->content = $this->blog->getAllTranslations('content');
//...
}
}
# Your livewire component
public function saveSomething(): void
{
$this->validate([
'categoryId' => [
'nullable',
'exists:blog_categories,id',
],
...$this->
class YourModel extends Model {
use LogsActivity; // обязательно подключите трейт от Spatie
use LogTranslatableAttributes;
public array $translatable = [
// ...
];
}