Skip to content

Commit

Permalink
Added attachment update request for update method instead of using At…
Browse files Browse the repository at this point in the history
…tchmentRequest (#36)

Co-authored-by: David <david.katalinic@asseco-see.hr>
  • Loading branch information
DaveXo9 and David authored Jan 26, 2024
1 parent 0853147 commit a61f7d4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/App/Http/Controllers/AttachmentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Asseco\Attachments\App\Contracts\Attachment as AttachmentContract;
use Asseco\Attachments\App\Http\Requests\AttachmentRequest;
use Asseco\Attachments\App\Http\Requests\AttachmentUpdateRequest;
use Asseco\Attachments\App\Models\Attachment;
use Exception;
use Illuminate\Http\JsonResponse;
Expand Down Expand Up @@ -66,7 +67,7 @@ public function show(Attachment $attachment): JsonResponse
* @param AttachmentRequest $request
* @return JsonResponse
*/
public function update(Attachment $attachment, AttachmentRequest $request): JsonResponse
public function update(Attachment $attachment, AttachmentUpdateRequest $request): JsonResponse
{
$attachment->update($request->validated());

Expand Down
32 changes: 32 additions & 0 deletions src/App/Http/Requests/AttachmentUpdateRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace Asseco\Attachments\App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class AttachmentUpdateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'filing_purpose_id' => 'required|string|exists:filing_purposes,id',
];
}
}

0 comments on commit a61f7d4

Please sign in to comment.