phpstan add types
This commit is contained in:
@@ -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,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user