2023-06-11 12:14:03 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Modules\Translation\Entities;
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class TranslationTranslation extends Model
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Indicates if the model should be timestamped.
|
|
|
|
*
|
|
|
|
* @var bool
|
|
|
|
*/
|
|
|
|
public $timestamps = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $fillable = ['locale', 'value'];
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
2023-06-11 12:14:03 +00:00
|
|
|
/**
|
2023-12-03 14:07:47 +00:00
|
|
|
* Clear translations cache.
|
2023-06-11 12:14:03 +00:00
|
|
|
*
|
2023-12-03 14:07:47 +00:00
|
|
|
* @return bool
|
2023-06-11 12:14:03 +00:00
|
|
|
*/
|
2023-12-03 14:07:47 +00:00
|
|
|
public static function clearCache()
|
2023-06-11 12:14:03 +00:00
|
|
|
{
|
2023-12-03 14:07:47 +00:00
|
|
|
Cache::tags('translations')->flush();
|
2023-06-11 12:14:03 +00:00
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
2023-06-11 12:14:03 +00:00
|
|
|
/**
|
2023-12-03 14:07:47 +00:00
|
|
|
* Perform any actions required after the model boots.
|
2023-06-11 12:14:03 +00:00
|
|
|
*
|
2023-12-03 14:07:47 +00:00
|
|
|
* @return void
|
2023-06-11 12:14:03 +00:00
|
|
|
*/
|
2023-12-03 14:07:47 +00:00
|
|
|
protected static function booted()
|
2023-06-11 12:14:03 +00:00
|
|
|
{
|
2023-12-03 14:07:47 +00:00
|
|
|
static::saved(function ($translationTranslation) {
|
|
|
|
$translationTranslation->clearCache();
|
|
|
|
});
|
2023-06-11 12:14:03 +00:00
|
|
|
}
|
|
|
|
}
|