<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ceedcv-maya / shared-translations-laravel example snippets
use Maya\Translations\Migrations as TranslationMigrations;
$this->loadMigrationsFrom(TranslationMigrations::translations());
use Illuminate\Database\Eloquent\Relations\Relation;
Relation::enforceMorphMap(['panel_alert' => \App\Models\PanelAlert::class]);
use Maya\Translations\Concerns\HasTranslations;
class PanelAlert extends Model
{
use HasTranslations;
protected array $translatable = ['text', 'action_label'];
}
// Escritura (reemplaza todas las traducciones del campo)
$alert->syncTranslations('text', ['es' => 'Hola', 'va' => 'Hola']);
// Lectura con fallback
$alert->translate('text', 'va', 'es');
// Serialización para API / payload de notificación
$alert->translationsMap(); // { "text": { "es": "…", "va": "…" }, ... }
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.