| Current Path : /home/users/unlimited/www/ultimate-ai.codeskitter.site/app/Models/Concerns/ |
| Current File : /home/users/unlimited/www/ultimate-ai.codeskitter.site/app/Models/Concerns/HasCacheFirst.php |
<?php
namespace App\Models\Concerns;
use Illuminate\Support\Facades\Cache;
trait HasCacheFirst
{
public static function getCache()
{
return Cache::remember(self::$cacheKey, self::$cacheTtl, static function () {
return self::query()->first();
});
}
public static function forgetCache(): void
{
Cache::forget(self::$cacheKey);
}
}