$params['title'], 'desc' => $params['desc'] ?? '', 'author' => $params['author'] ?? '', //作者 'sort' => $params['sort'] ?? 0, // 排序 'abstract' => $params['abstract'], // 文章摘要 'click_virtual' => $params['click_virtual'] ?? 0, 'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '', 'cid' => $params['cid'], 'is_show' => $params['is_show'], 'content' => $params['content'] ?? '', ]); } /** * @notes 编辑资讯 * @param array $params * @return bool * @author heshihu * @date 2022/2/22 10:12 */ public static function edit(array $params) : bool { try { Article::update([ 'id' => $params['id'], 'title' => $params['title'], 'desc' => $params['desc'] ?? '', // 简介 'author' => $params['author'] ?? '', //作者 'sort' => $params['sort'] ?? 0, // 排序 'abstract' => $params['abstract'], // 文章摘要 'click_virtual' => $params['click_virtual'] ?? 0, 'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '', 'cid' => $params['cid'], 'is_show' => $params['is_show'], 'content' => $params['content'] ?? '', ]); return true; } catch (\Exception $e) { self::setError($e->getMessage()); return false; } } /** * @notes 删除资讯 * @param array $params * @author heshihu * @date 2022/2/22 10:17 */ public static function delete(array $params) { Article::destroy($params['id']); } /** * @notes 查看资讯详情 * @param $params * @return array * @author heshihu * @date 2022/2/22 10:15 */ public static function detail($params) : array { return Article::findOrEmpty($params['id'])->toArray(); } /** * @notes 更改资讯状态 * @param array $params * @return bool * @author heshihu * @date 2022/2/22 10:18 */ public static function updateStatus(array $params) { Article::update([ 'id' => $params['id'], 'is_show' => $params['is_show'] ]); return true; } }