cfmgrv4 init...3
This commit is contained in:
parent
a4c262bfaf
commit
36322a95de
@ -77,7 +77,9 @@ abstract class MVController extends CommonController
|
|||||||
return $formDatas;
|
return $formDatas;
|
||||||
}
|
}
|
||||||
// 생성
|
// 생성
|
||||||
protected function create_form_process(): void {}
|
protected function create_form_process(): void
|
||||||
|
{
|
||||||
|
}
|
||||||
final protected function create_form_procedure(): RedirectResponse|string
|
final protected function create_form_procedure(): RedirectResponse|string
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -108,7 +110,7 @@ abstract class MVController extends CommonController
|
|||||||
{
|
{
|
||||||
$this->create_validate($this->action, $this->fields);
|
$this->create_validate($this->action, $this->fields);
|
||||||
$this->formDatas = $this->getFormDatas();
|
$this->formDatas = $this->getFormDatas();
|
||||||
$this->entity = $this->getModel()->create(formDatas: $this->formDatas);
|
$this->entity = $this->getModel()->create($this->formDatas);
|
||||||
}
|
}
|
||||||
protected function create_process_result(): RedirectResponse|string
|
protected function create_process_result(): RedirectResponse|string
|
||||||
{
|
{
|
||||||
|
|||||||
10
app/Services/Common.php
Normal file
10
app/Services/Common.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
abstract class Common
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
43
app/Services/User.php
Normal file
43
app/Services/User.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?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();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user