dealhub/app/Http/Requests/StoreBrokerProfileRequest.php
kusowl c087126080 feature(admin-panel): manage broker section
- admin can edit, approve or reject broker registration
- admin can edit, delete or impersonate as broker
2026-01-28 13:44:05 +05:30

46 lines
1.3 KiB
PHP

<?php
namespace App\Http\Requests;
use AllowDynamicProperties;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
#[AllowDynamicProperties]
class StoreBrokerProfileRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
// If this request is by a broker profile, then only allow the owner to update it.
if (isset($this->profile)) {
$this->user = $this->profile;
return $this->user()->id === $this->profile->id;
}
// If this request is by an admin, then allow them to update any profile.
$this->user = $this->broker->user;
return $this->user()->isAdmin();
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => 'required|string|min:3|max:255',
'bio' => 'required|string|min:10|max:255',
'email' => ['required', 'email', 'max:255', Rule::unique('users')->ignore($this->user->id)],
'phone' => 'required|string|min:10|max:255',
'location' => 'required|string|min:3|max:255',
];
}
}