38 lines
840 B
PHP
38 lines
840 B
PHP
![]() |
<?php
|
||
|
|
||
|
namespace app\api\logic\user;
|
||
|
|
||
|
use app\common\logic\BaseLogic;
|
||
|
use app\common\model\user\UserFeedback;
|
||
|
use think\facade\Db;
|
||
|
|
||
|
class UserFeedbackLogic extends BaseLogic
|
||
|
{
|
||
|
/**
|
||
|
* @notes 添加用户反馈表
|
||
|
* @param array $params
|
||
|
* @return bool
|
||
|
* @author likeadmin
|
||
|
* @date 2024/05/13 16:56
|
||
|
*/
|
||
|
public static function add(array $params): bool
|
||
|
{
|
||
|
Db::startTrans();
|
||
|
try {
|
||
|
UserFeedback::create([
|
||
|
'uid' => $params['uid'],
|
||
|
'content' => $params['content'],
|
||
|
'images' => $params['images'] ? json_encode($params['images']) : null,
|
||
|
'name' => $params['name'],
|
||
|
'contact' => $params['contact'],
|
||
|
'create_time' => time(),
|
||
|
]);
|
||
|
Db::commit();
|
||
|
return true;
|
||
|
} catch (\Exception $e) {
|
||
|
Db::rollback();
|
||
|
self::setError($e->getMessage());
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
}
|