Skip to content

Commit

Permalink
fix notification
Browse files Browse the repository at this point in the history
  • Loading branch information
mazfreelance committed Jan 22, 2023
1 parent 54164ee commit fbf8638
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 44 deletions.
8 changes: 4 additions & 4 deletions app/Containers/v1/Notification/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ public function read(string $notificationId)
*
* @return \Illuminate\Http\JsonResponse
*/
public function multiRead(MultiReadRequest $request)
public function multiRead(Request $request)
{
$notificationStoreDTO = NotificationStoreDTO::fromRequest($request);
$notificationStoreDTO = NotificationStoreDTO::from($request);
Executor::run('Notification@MultiReadAction', $notificationStoreDTO);

return Responder::success([], __('message.success_update'));
Expand All @@ -88,9 +88,9 @@ public function multiRead(MultiReadRequest $request)
*
* @return \Illuminate\Http\JsonResponse
*/
public function multiDelete(MultiDeleteRequest $request)
public function multiDelete(Request $request)
{
$notificationStoreDTO = NotificationStoreDTO::fromRequest($request);
$notificationStoreDTO = NotificationStoreDTO::from($request);
Executor::run('Notification@MultiDeleteAction', $notificationStoreDTO);

return Responder::success([], __('message.success_delete'));
Expand Down
26 changes: 18 additions & 8 deletions app/Containers/v1/Notification/DTO/NotificationStoreDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,27 @@

namespace App\Containers\v1\Notification\DTO;

use Illuminate\Http\Request;
use Spatie\DataTransferObject\DataTransferObject;
use Spatie\LaravelData\Data;

class NotificationStoreDTO extends DataTransferObject
/**
* @reference https://github.com/spatie/data-transfer-object
*/
class NotificationStoreDTO extends Data
{
public $notification_ids;
public function __construct(
public array $notification_ids
) {}

public static function fromRequest(Request $request): self
/**
* to construct a custom rule object
*
* @reference https://laravel.com/docs/9.x/validation
*/
public static function rules(): array
{
return new self([
'notification_ids' => $request->notification_ids
]);
return [
'notification_ids' => ['required', 'array', 'bail'],
'notification_ids.*' => ['integer', 'max:36', 'bail']
];
}
}
16 changes: 0 additions & 16 deletions app/Containers/v1/Notification/Requests/MultiDeleteRequest.php

This file was deleted.

16 changes: 0 additions & 16 deletions app/Containers/v1/Notification/Requests/MultiReadRequest.php

This file was deleted.

0 comments on commit fbf8638

Please sign in to comment.