TraceDash/app/Http/Requests/ViewerRequest.php

39 lines
766 B
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Auth;
class ViewerRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
if (!Auth::check()) {
return false;
}
$user = Auth::user();
if ($user->is_admin) {
return true;
}
$channels = $user->getTraceChannels();
return $channels->isNotEmpty();
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [];
}
}