phpstan add types

This commit is contained in:
2025-03-10 16:27:45 +05:00
parent 3701265a0a
commit 11df811e0c
4 changed files with 32 additions and 9 deletions

View File

@@ -2,15 +2,24 @@
namespace App\Http\Controllers;
use App\Models\Alert;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Http\JsonResponse;
class AlertController extends Controller
{
/**
* Get alerts for user
*/
public function index()
public function index(): JsonResponse
{
$alerstQuery = auth()->user()->alerts()->whereNull('seen_at');
/** @var \App\Models\User */
$user = auth()->user();
/** @var \Illuminate\Database\Eloquent\Builder<Alert> */
$alerstQuery = $user->alerts()->whereNull('seen_at');
/** @var Collection<array-key, Alert> */
$alerts = $alerstQuery->get();
$alerstQuery->update([
@@ -22,10 +31,13 @@ class AlertController extends Controller
/**
* Format
*
* @param Collection<array-key, Alert> $alerts
* @return Collection<array-key, Alert>
*/
public function format($alerts)
public function format(Collection $alerts): Collection
{
return $alerts->map(fn ($alert) => [
return $alerts->map(fn (Alert $alert) => [
'name' => $alert->name,
'value' => $alert->value,
]);