Skip to content

Commit

Permalink
feat: create dto
Browse files Browse the repository at this point in the history
  • Loading branch information
deniskorbakov committed Oct 26, 2024
1 parent 897f7a2 commit 1d72d25
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions app/DTO/Api/User/Request/UserUpdateDTO.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

namespace App\DTO\Api\User\Request;

use Illuminate\Http\UploadedFile;
use Illuminate\Validation\Rule;
use Spatie\LaravelData\Attributes\Validation\Image;
use Spatie\LaravelData\Attributes\Validation\Max;
use Spatie\LaravelData\Data;
use Spatie\LaravelData\Support\Validation\ValidationContext;

class UserUpdateDTO extends Data
{
public function __construct(
#[Image]
public ?UploadedFile $image,
#[Max(255)]
public ?string $name,
#[Max(255)]
public ?string $surname,
#[Max(255)]
public ?string $patronymic,
#[Max(255)]
public ?string $email,
#[Max(255)]
public ?string $about,
) {
}

public static function rules(ValidationContext $context): array
{
return [
'email' => [
'email',
Rule::unique('users', 'email')->ignore(auth()->id()),
],
];
}
}

0 comments on commit 1d72d25

Please sign in to comment.