orisai/nextras-object-mapper

orisai/object-mapper extension for nextras/orm

v1.x-dev 2024-06-21 22:24 UTC

This package is auto-updated.

Last update: 2024-12-21 23:23:58 UTC


README

Orisai
Nextras Object Mapper

orisai/object-mapper extension for nextras/orm

📄 Check out our documentation.

💸 If you like Orisai, please make a donation. Thank you!

use App\User\DB\User;
use OriNextras\ObjectMapper\Rules\EntityFromId;
use Orisai\ObjectMapper\Attributes\Expect\IntValue;
use Orisai\ObjectMapper\Attributes\Modifiers\FieldName;
use Orisai\ObjectMapper\MappedObject;

final class EntityFetchingInput implements MappedObject
{

	/**
	 * @FieldName("userId")
	 * @EntityFromId(
	 *     name="userId"
	 *     entity=User::class
	 *     idRule=@IntValue(unsigned=true, castNumericString=true)
	 * )
	 */
	public User $user;

}
$data = [
	'userId' => 666,
];
$input = $processor->process($data, EntityFetchingInput::class);
// $input == EntityFetchingInput(user: User(id: 666, /* ... */))