You've already forked Epicnabbo-Catalogus-Updated-Daily
36 lines
898 B
PHP
36 lines
898 B
PHP
<?php
|
|
|
|
namespace App\Services\Community;
|
|
|
|
use App\Models\Community\Teams\WebsiteTeam;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class TeamService
|
|
{
|
|
/**
|
|
* @return Collection<int, WebsiteTeam>
|
|
*/
|
|
public function fetchTeams(): Collection
|
|
{
|
|
$cacheEnabled = setting('enable_caching') === '1';
|
|
|
|
if (Cache::has('hotel_teams') && $cacheEnabled) {
|
|
/** @var Collection<int, WebsiteTeam> */
|
|
return Cache::get('hotel_teams');
|
|
}
|
|
|
|
/** @var Collection<int, WebsiteTeam> $teams */
|
|
$teams = WebsiteTeam::where('is_active', true)
|
|
->orderBy('name')
|
|
->get();
|
|
|
|
if ($cacheEnabled) {
|
|
$cacheTimer = (int) setting('cache_timer');
|
|
Cache::put('hotel_teams', $teams, now()->addMinutes($cacheTimer));
|
|
}
|
|
|
|
return $teams;
|
|
}
|
|
}
|