2023-12-19 21:57:23 +01:00
|
|
|
<?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
|
|
|
|
{
|
2023-12-19 23:10:45 +01:00
|
|
|
if (!Auth::check()) {
|
2023-12-19 21:57:23 +01:00
|
|
|
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 [];
|
|
|
|
}
|
|
|
|
}
|