You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.7 KiB

7 years ago
4 years ago
6 years ago
7 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use Illuminate\Support\Facades\DB;
  4. use App\Common\Helper;
  5. use App\Common\ReturnData;
  6. use Illuminate\Http\Request;
  7. use App\Http\Logic\FriendlinkLogic;
  8. use App\Http\Model\Friendlink;
  9. class FriendlinkController extends BaseController
  10. {
  11. public function __construct()
  12. {
  13. parent::__construct();
  14. }
  15. public function getLogic()
  16. {
  17. return new FriendlinkLogic();
  18. }
  19. public function index(Request $request)
  20. {
  21. $res = '';
  22. $where = function ($query) use ($res) {
  23. if(isset($_REQUEST["keyword"]))
  24. {
  25. $query->where('webname', 'like', '%'.$_REQUEST['keyword'].'%');
  26. }
  27. if(isset($_REQUEST["group_id"]))
  28. {
  29. $query->where('group_id', $_REQUEST["group_id"]);
  30. }
  31. };
  32. $posts = $this->getLogic()->getPaginate($where, array('listorder', 'asc'));
  33. $data['posts'] = $posts;
  34. return view('admin.friendlink.index', $data);
  35. }
  36. public function add(Request $request)
  37. {
  38. return view('admin.friendlink.add');
  39. }
  40. public function doadd(Request $request)
  41. {
  42. if(Helper::isPostRequest())
  43. {
  44. $res = $this->getLogic()->add($_POST);
  45. if($res['code'] == ReturnData::SUCCESS)
  46. {
  47. success_jump($res['msg'], route('admin_friendlink'));
  48. }
  49. error_jump($res['msg']);
  50. }
  51. }
  52. public function edit(Request $request)
  53. {
  54. if(!checkIsNumber($request->input('id',null))){error_jump('参数错误');}
  55. $id = $request->input('id');
  56. $data['id'] = $where['id'] = $id;
  57. $data['post'] = $this->getLogic()->getOne($where);
  58. return view('admin.friendlink.edit', $data);
  59. }
  60. public function doedit(Request $request)
  61. {
  62. if(!checkIsNumber($request->input('id',null))){error_jump('参数错误');}
  63. $id = $request->input('id');
  64. if(Helper::isPostRequest())
  65. {
  66. $where['id'] = $id;
  67. $res = $this->getLogic()->edit($_POST, $where);
  68. if($res['code'] == ReturnData::SUCCESS)
  69. {
  70. success_jump($res['msg'], route('admin_friendlink'));
  71. }
  72. error_jump($res['msg']);
  73. }
  74. }
  75. public function del(Request $request)
  76. {
  77. if(!checkIsNumber($request->input('id',null))){error_jump('参数错误');}
  78. $id = $request->input('id');
  79. $where['id'] = $id;
  80. $res = $this->getLogic()->del($where);
  81. if($res['code'] == ReturnData::SUCCESS)
  82. {
  83. success_jump($res['msg']);
  84. }
  85. error_jump($res['msg']);
  86. }
  87. }