/** * 注册公共数据 */ public function setCommonData() { $data['navigationList'] = Navigation::getNavigationTreeArray(); //导航列表数组 $data['hotArticleList'] = Article::getHotArticleList(5); //热门文章列表 $data['tagsList'] = Tags::orderBy('number', 'desc')->limit(15)->get(); //标签云 $data['linkList'] = Links::orderBy('sequence')->limit(10)->get(); //友情链接列表 View::share($data); }
/** * Finds the Links model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Links the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Links::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { if ($result = check_auth_to('YQLJ_DELETE')) { return $result; } try { Links::destroy($id); return redirect()->action('Admin\\LinksController@index')->with('operationstatus', 'sucess'); } catch (\Exception $e) { return redirect()->back()->withErrors(['error' => '删除友情链接失败,请重试(' . $e->getMessage() . ')']); } }