multi-store/app/admin/logic/user/UserFeedbackLogic.php
2024-05-30 21:37:55 +08:00

102 lines
2.3 KiB
PHP

<?php
namespace app\admin\logic\user;
use app\common\logic\BaseLogic;
use app\common\model\user\UserFeedback;
use think\facade\Db;
/**
* 用户反馈表逻辑
* Class UserFeedbackLogic
* @package app\admin\logic\user
*/
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'],
'name' => $params['name'],
'contact' => $params['contact']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑用户反馈表
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/05/13 16:56
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
UserFeedback::where('id', $params['id'])->update([
'uid' => $params['uid'],
'content' => $params['content'],
'images' => $params['images'],
'name' => $params['name'],
'contact' => $params['contact']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除用户反馈表
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/05/13 16:56
*/
public static function delete(array $params): bool
{
return UserFeedback::destroy($params['id']);
}
/**
* @notes 获取用户反馈表详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/05/13 16:56
*/
public static function detail($params): array
{
return UserFeedback::findOrEmpty($params['id'])->toArray();
}
}