cfmgrv4/app/Services/User.php
2024-10-23 19:45:07 +09:00

44 lines
1.0 KiB
PHP

<?php
namespace App\Services;
use App\Models\UserModel;
use App\Entities\UserEntity;
class User extends Common
{
private ?UserModel $_model = null;
public function __construct()
{
parent::__construct();
}
public function getModel(): UserModel
{
if ($this->_model === null) {
$this->_model = new UserModel();
}
return $this->_model;
}
public function find(array $wheres): ?UserEntity
{
return $this->getModel()->where($wheres)->first();
}
public function findAll(array $wheres = []): array
{
return $this->getModel()->where($wheres)->findAll();
}
public function create(array $formDatas): UserEntity
{
return $this->getModel()->create($formDatas);
}
public function modify(UserEntity $entity, array $formDatas): UserEntity
{
return $this->getModel()->modify($entity, $formDatas);
}
public function delete(array $wheres): void
{
$this->getModel()->where($wheres)->delete();
}
}