34 lines
826 B
PHP
34 lines
826 B
PHP
|
<?php
|
||
|
|
||
|
namespace kernel\app_modules\photo\services;
|
||
|
|
||
|
use kernel\app_modules\photo\models\Photo;
|
||
|
use kernel\FormModel;
|
||
|
use kernel\helpers\Debug;
|
||
|
|
||
|
class PhotoService
|
||
|
{
|
||
|
public function create(FormModel $form_model): false|Photo
|
||
|
{
|
||
|
$model = new Photo();
|
||
|
$model->image = $form_model->getItem('image');
|
||
|
$model->entity = $form_model->getItem('entity');
|
||
|
$model->entity_id = $form_model->getItem('entity_id');
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
public function update(FormModel $form_model, Photo $photo): false|Photo
|
||
|
{
|
||
|
$photo->image = $form_model->getItem('image');
|
||
|
$photo->entity = $form_model->getItem('entity');
|
||
|
$photo->entity_id = $form_model->getItem('entity_id');
|
||
|
|
||
|
if ($photo->save()){
|
||
|
return $photo;
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
}
|