37 lines
816 B
PHP
37 lines
816 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Models\SeatingLimit;
|
|
use Illuminate\Support\Facades\Cache;
|
|
use function Pest\Laravel\get;
|
|
|
|
class SeatingService
|
|
{
|
|
protected $limitsCacheKey = 'acceptanceLimits';
|
|
/**
|
|
* Create a new class instance.
|
|
*/
|
|
public function __construct()
|
|
{
|
|
//
|
|
}
|
|
|
|
public function getAcceptanceLimits()
|
|
{
|
|
// TODO modifying audition limits should refresh this cache
|
|
return Cache::remember($this->limitsCacheKey, now()->addDay(), function () {
|
|
return SeatingLimit::all()->groupBy('audition_id');
|
|
});
|
|
}
|
|
|
|
public function getLimitForAudition($auditionId)
|
|
{
|
|
return $this->getAcceptanceLimits()[$auditionId];
|
|
}
|
|
|
|
public function refershLimits() {
|
|
Cache::forget($this->limitsCacheKey);
|
|
}
|
|
}
|