add notifications logic and add support of both JWT and Sanctum
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Notifications;
|
||||
|
||||
use App\Http\Requests\ApiFormRequest;
|
||||
|
||||
class NotificationActiveRequest extends ApiFormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user() !== null;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'target_group' => ['nullable', 'string', 'max:50'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Notifications;
|
||||
|
||||
use App\Http\Requests\ApiFormRequest;
|
||||
|
||||
class NotificationDeletedRequest extends ApiFormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user() !== null;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Notifications;
|
||||
|
||||
use App\Http\Requests\ApiFormRequest;
|
||||
|
||||
class NotificationIndexRequest extends ApiFormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user() !== null;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'read' => ['nullable', 'boolean'],
|
||||
'page' => ['nullable', 'integer', 'min:1'],
|
||||
'per_page' => ['nullable', 'integer', 'min:1', 'max:200'],
|
||||
'sort_by' => ['nullable', 'string', 'in:created_at,scheduled_at,priority'],
|
||||
'sort_dir' => ['nullable', 'string', 'in:asc,desc'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Notifications;
|
||||
|
||||
use App\Http\Requests\ApiFormRequest;
|
||||
|
||||
class NotificationSendRequest extends ApiFormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user() !== null;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => ['required', 'string', 'max:150'],
|
||||
'message' => ['required', 'string', 'max:5000'],
|
||||
'target_group' => ['required', 'string', 'max:50'],
|
||||
'channels' => ['required', 'array'],
|
||||
'channels.*' => ['string', 'in:in_app,email,sms'],
|
||||
'priority' => ['nullable', 'string', 'max:20'],
|
||||
'status' => ['nullable', 'string', 'max:20'],
|
||||
'action_url' => ['nullable', 'string', 'max:255'],
|
||||
'attachment_path' => ['nullable', 'string', 'max:255'],
|
||||
'scheduled_at' => ['nullable', 'date'],
|
||||
'expires_at' => ['nullable', 'date', 'after_or_equal:scheduled_at'],
|
||||
'school_year' => ['nullable', 'string', 'max:20'],
|
||||
'semester' => ['nullable', 'string', 'max:20'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Notifications;
|
||||
|
||||
use App\Http\Requests\ApiFormRequest;
|
||||
|
||||
class NotificationUpdateRequest extends ApiFormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user() !== null;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => ['sometimes', 'required', 'string', 'max:150'],
|
||||
'message' => ['sometimes', 'required', 'string', 'max:5000'],
|
||||
'target_group' => ['sometimes', 'required', 'string', 'max:50'],
|
||||
'channels' => ['sometimes', 'required', 'array'],
|
||||
'channels.*' => ['string', 'in:in_app,email,sms'],
|
||||
'priority' => ['nullable', 'string', 'max:20'],
|
||||
'status' => ['nullable', 'string', 'max:20'],
|
||||
'action_url' => ['nullable', 'string', 'max:255'],
|
||||
'attachment_path' => ['nullable', 'string', 'max:255'],
|
||||
'scheduled_at' => ['nullable', 'date'],
|
||||
'expires_at' => ['nullable', 'date', 'after_or_equal:scheduled_at'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user