field(true) ->where($where) ->with(['vote']) ->order('id', 'desc') ->paginate([ 'page' => $get['page'], 'list_rows' => $get['limit'], 'var_page' => 'page' ]) ->toArray(); foreach ($lists['data'] as &$item) { $item['vote_title'] = $item['vote']['title'] ?? ''; $item['add_time'] = $item['add_time']? date("Y-m-d H:i:s",$item['add_time']):""; $item['status'] = $item['status'] ? '显示' : '隐藏'; } return ['count'=>$lists['total'], 'lists'=>$lists['data']]; } catch (Exception $e) { return ['error'=>$e->getMessage()]; } } /** * @Notes: 资料详细 * @Author: * @param $id * @return array */ public static function detail($id) { $model = new VotePlayer(); $detail = $model->field(true)->findOrEmpty($id)->toArray(); $detail['images_arr'] = $detail['images']? explode(",",$detail['images']):[]; return $detail; } /** * @Notes: 添加帮助 * @Author: * @param $post * @return bool */ public static function add($post) { try { if(isset($post['goods_image']) && count($post['goods_image'])){ $post['images'] = implode(",",$post['goods_image']); } VotePlayer::create([ 'vote_id' => $post['vote_id']??0, 'name' => $post['name'], 'avatar' => $post['avatar'] ?? '', 'video' => $post['video'] ?? '', 'images' => $post['images'] ?? '', 'intro' => $post['intro'] ?? '', 'vote_num' => $post['vote_num'] ?? 0, 'base_visit' => $post['base_visit'] ?? 0, 'status' => $post['status'] ?? 1, 'vote_total' => 0, 'views' => 0, 'add_time' => time(), ]); return true; } catch (\Exception $e) { static::$error = $e->getMessage(); return false; } } /** * @Notes: 编辑帮助 * @Author: 张无忌 * @param $post * @return bool */ public static function edit($post) { try { if(isset($post['goods_image']) && count($post['goods_image'])){ $post['images'] = implode(",",$post['goods_image']); } VotePlayer::update([ 'vote_id' => $post['vote_id']??0, 'name' => $post['name'], 'avatar' => $post['avatar'] ?? '', 'video' => $post['video'] ?? '', 'images' => $post['images'] ?? '', 'intro' => $post['intro'] ?? '', 'vote_num' => $post['vote_num'] ?? 0, 'base_visit' => $post['base_visit'] ?? 0, 'status' => $post['status'] ?? 1, 'update_time' => time(), ], ['id'=>$post['id']]); return true; } catch (\Exception $e) { static::$error = $e->getMessage(); return false; } } /** * @Notes: 删除 * @Author: * @param $id * @return bool */ public static function del($id) { try { VotePlayer::update([ 'del' => 1, 'update_time' => time() ], ['id'=>$id]); return true; } catch (\Exception $e) { static::$error = $e->getMessage(); return false; } } /** * @Notes: 隐藏 * @Author: 张无忌 * @param $id * @return bool */ public static function status($id,$status) { try { VotePlayer::update([ 'status' => $status, 'update_time' => time() ], ['id'=>$id]); return true; } catch (\Exception $e) { static::$error = $e->getMessage(); return false; } } }