my-idlers/app/Models/Locations.php
cp6 d3125170e6 Fixed locations cache
Fixed locations cache
2022-05-09 15:00:33 +10:00

25 lines
540 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class Locations extends Model
{
use HasFactory;
protected $fillable = ['name'];
protected $table = 'locations';
public static function allLocations(): array
{
return Cache::remember("locations", now()->addMonth(1), function () {
return DB::table('locations')->get()->toArray();
});
}
}