1. Go to this page and download the library: Download k2gl/entity-exist library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
k2gl / entity-exist example snippets
use K2gl\Component\Validator\Constraint\EntityExist\AssertEntityNotExist;
readonly class RegisterUserOrder
{
public function __construct(
#[Assert\NotBlank]
#[Assert\Email]
#[AssertEntityNotExist(
entity: User::class,
property: 'email',
message: 'User with email "%value%" already registered.'
)]
public string $email,
) {
}
}
use K2gl\Component\Validator\Constraint\EntityExist\AssertEntityExist;
readonly class TransferUserToOtherUnitOrder
{
public function __construct(
#[Assert\NotBlank]
#[AssertEntityExist(
entity: User::class,
property: 'uuid',
)]
public string $user,
#[Assert\NotBlank]
#[AssertEntityExist(
entity: Unit::class,
property: 'uuid',
)]
public string $unit,
) {
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.