Files
backend/app/Http/Requests/Auth/LoginRequest.php
2025-07-22 09:35:20 +03:30

33 lines
784 B
PHP

<?php
namespace App\Http\Requests\Auth;
use App\Models\User;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
class LoginRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return !User::query()->where('username', '=', $this->username)->value('is_online');
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array|string>
*/
public function rules(): array
{
return [
'username' => 'required|exists:users,username',
'password' => 'required|string',
];
}
}