1
0
mirror of https://github.com/cp6/my-idlers.git synced 2024-11-16 15:33:44 +01:00
my-idlers/app/Models/Locations.php

26 lines
540 B
PHP

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