<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\App;

class Lang extends Model
{
    use HasFactory;
    protected $fillable=['locale','key','value'];

    protected static function booted()
    {
        static::created(function ($user) {
            static::removeLangCache();
        });
        static::updated(function ($user) {
            static::removeLangCache();
        });
        static::deleted(function ($user) {
            static::removeLangCache();
        });
    }


    public static function removeLangCache()
    {
        Cache::forget('lang.ar');
    }
}
