Interfaces
Contract User
This is an Interface of an User. Contract User is a child of Contract Content, and has more abilities.
namespace MetaFox\Platform\Contracts;
interface User extends Content, BigNumberId
{
/**
* Result must contain entity_type, user_name, user_image, name.
*
* @return array<string, mixed>
*/
public function toUserResource(): array;
/**
* Determine if resource can be blocked.
*
* @return bool
*/
public function canBeBlocked(): bool;
}
A special ability of a Contract User is that it uses BigNumberId
to set ID (with setEntityId
method) for entities tables ( to support global and unique ID for all resources).
namespace MetaFox\Platform\Contracts;
interface BigNumberId
{
public function entityId();
public function setEntityId(int $id);
public function entityType();
}
To define which details are stored in entities table, we can use the toUserResource()
method. For example: in User, you can define this method as below:
public function toUserResource()
{
return [
'entity_type' => $this->entityType(),
'user_name' => $this->user_name,
'user_image' => $this->profile != null ? $this->profile->user_image : null,
'name' => $this->full_name,
];
}