ldc-mesbr-app/app/Http/Requests/Campaign/StoreNotifCampaign.php
2026-10-28 12:27:46 +01:00

37 lines
944 B
PHP

<?php
namespace App\Http\Requests\Campaign;
use App\Enums\UserRoles;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\Rule;
class StoreNotifCampaign extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return Auth::check() && (Auth::user()->roles === UserRoles::superadmin()->value || Auth::user()->roles === UserRoles::admin()->value);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'notif_name' => 'min:5|required',
'notif_email' => [
'required',
Rule::unique('notification')->where(fn($query) => $query->where('notif_campId', $this->campaign->camp_id)),
]
];
}
}