Files
aibuddytool/app/View/Composers/StatsComposer.php
2023-11-28 17:38:49 +08:00

24 lines
535 B
PHP

<?php
namespace App\View\Composers;
use App\Models\AiTool;
use Illuminate\Support\Facades\Cache;
use Illuminate\View\View;
class StatsComposer
{
public function compose(View $view)
{
$seconds_to_remember = 600;
// Retrieve the count from the cache or count and store it if not present
$tools_count = Cache::remember('tools_count_' . $seconds_to_remember, $seconds_to_remember, function () {
return AiTool::count();
});
$view->with('tools_count', $tools_count);
}
}