/** * 执行任务 * * @param $title * @param $url * @param $cat_id */ public static function task($title, $url, $cat_id) { $news = NewsModel::where('title', '=', $title)->orWhere('site_url', '=', $url)->first(); if (empty($news)) { NewsModel::create(['title' => $title, 'site_url' => $url, 'status' => 1, 'news_cat_id' => $cat_id]); } }
/** * 删除数据 * * @param $id * @throws \Exception * @author yangyifan <*****@*****.**> */ public function getDelete($id) { NewsModel::del($id) > 0 ? $this->response(200, trans('response.delete_success'), [], false, url('admin/news/index')) : $this->response(400, trans('response.delete_error'), [], false); }
/** * 添加文章 * * @param Request $request * @author yangyifan <*****@*****.**> */ public function postAdd(NewsRequest $request) { $data = $request->all(); //写入当前用户到数据 $data['admin_info_id'] = $request->get('admin_info_id', Session::get('admin_info.id')); //写入数据 $affected_number = NewsModel::create($data); return $affected_number->id > 0 ? $this->response(200, trans('response.add_success'), [], true, url('admin/news/index')) : $this->response(400, trans('response.add_error'), [], false); }