From 6e3a61620f75019837d1a970794b3b5542c0673d Mon Sep 17 00:00:00 2001 From: "ZLW-PC\\Administrator" <374861669@qq.com> Date: Fri, 22 Dec 2017 17:36:06 +0800 Subject: [PATCH] kuaidi --- .../Controllers/Admin/BonusController.php | 92 +++++++++++++++++++ .../Controllers/Admin/KuaidiController.php | 92 +++++++++++++++++++ app/Http/Controllers/Admin/UserController.php | 32 ++++--- .../Controllers/Admin/UserRankController.php | 12 ++- app/Http/Model/Kuaidi.php | 30 ++++++ resources/views/admin/bonus/add.blade.php | 79 ++++++++++++++++ resources/views/admin/bonus/edit.blade.php | 79 ++++++++++++++++ resources/views/admin/bonus/index.blade.php | 36 ++++++++ resources/views/admin/kuaidi/add.blade.php | 79 ++++++++++++++++ resources/views/admin/kuaidi/edit.blade.php | 79 ++++++++++++++++ resources/views/admin/kuaidi/index.blade.php | 36 ++++++++ resources/views/admin/user/add.blade.php | 44 ++++++--- resources/views/admin/userrank/add.blade.php | 75 ++------------- resources/views/admin/userrank/edit.blade.php | 75 ++------------- routes/web.php | 13 ++- 15 files changed, 685 insertions(+), 168 deletions(-) create mode 100644 app/Http/Controllers/Admin/BonusController.php create mode 100644 app/Http/Controllers/Admin/KuaidiController.php create mode 100644 app/Http/Model/Kuaidi.php create mode 100644 resources/views/admin/bonus/add.blade.php create mode 100644 resources/views/admin/bonus/edit.blade.php create mode 100644 resources/views/admin/bonus/index.blade.php create mode 100644 resources/views/admin/kuaidi/add.blade.php create mode 100644 resources/views/admin/kuaidi/edit.blade.php create mode 100644 resources/views/admin/kuaidi/index.blade.php diff --git a/app/Http/Controllers/Admin/BonusController.php b/app/Http/Controllers/Admin/BonusController.php new file mode 100644 index 0000000..9095a24 --- /dev/null +++ b/app/Http/Controllers/Admin/BonusController.php @@ -0,0 +1,92 @@ +$v) + { + $data['posts'][$k]->status_text = Bonus::getStatusText(array('status'=>$v->status)); + } + } + + return view('admin.bonus.index', $data); + } + + public function add() + { + if(Helper::isPostRequest()) + { + if(isset($_POST['editorValue'])){unset($_POST['editorValue']);} + unset($_POST["_token"]); + + if(DB::table('bonus')->insert(array_filter($_POST))) + { + success_jump('添加成功!', route('admin_bonus')); + } + else + { + error_jump('添加失败!请修改后重新添加'); + } + } + + return view('admin.bonus.add'); + } + + public function edit() + { + if(Helper::isPostRequest()) + { + if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else{$id="";exit;} + + if(isset($_POST['editorValue'])){unset($_POST['editorValue']);} + unset($_POST["_token"]); + + if(DB::table('bonus')->where('id', $id)->update($_POST)) + { + success_jump('修改成功!', route('admin_bonus')); + } + else + { + error_jump('修改失败!'); + } + } + + if(!empty($_GET["id"])){$id = $_GET["id"];}else{$id="";} + if(preg_match('/[0-9]*/',$id)){}else{exit;} + + $data['id'] = $id; + $data['post'] = object_to_array(DB::table('bonus')->where('id', $id)->first(), 1); + + return view('admin.bonus.edit', $data); + } + + public function del() + { + if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump('删除失败!请重新提交');} + + if(DB::table('bonus')->whereIn("id", explode(',', $id))->delete()) + { + success_jump('删除成功'); + } + else + { + error_jump('删除失败!请重新提交'); + } + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Admin/KuaidiController.php b/app/Http/Controllers/Admin/KuaidiController.php new file mode 100644 index 0000000..3a2895b --- /dev/null +++ b/app/Http/Controllers/Admin/KuaidiController.php @@ -0,0 +1,92 @@ +$v) + { + $data['posts'][$k]->status_text = Kuaidi::getStatusText(array('status'=>$v->status)); + } + } + + return view('admin.kuaidi.index', $data); + } + + public function add() + { + if(Helper::isPostRequest()) + { + if(isset($_POST['editorValue'])){unset($_POST['editorValue']);} + unset($_POST["_token"]); + + if(DB::table('kuaidi')->insert(array_filter($_POST))) + { + success_jump('添加成功!', route('admin_kuaidi')); + } + else + { + error_jump('添加失败!请修改后重新添加'); + } + } + + return view('admin.kuaidi.add'); + } + + public function edit() + { + if(Helper::isPostRequest()) + { + if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else{$id="";exit;} + + if(isset($_POST['editorValue'])){unset($_POST['editorValue']);} + unset($_POST["_token"]); + + if(DB::table('kuaidi')->where('id', $id)->update($_POST)) + { + success_jump('修改成功!', route('admin_kuaidi')); + } + else + { + error_jump('修改失败!'); + } + } + + if(!empty($_GET["id"])){$id = $_GET["id"];}else{$id="";} + if(preg_match('/[0-9]*/',$id)){}else{exit;} + + $data['id'] = $id; + $data['post'] = object_to_array(DB::table('kuaidi')->where('id', $id)->first(), 1); + + return view('admin.kuaidi.edit', $data); + } + + public function del() + { + if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump('删除失败!请重新提交');} + + if(DB::table('kuaidi')->whereIn("id", explode(',', $id))->delete()) + { + success_jump('删除成功'); + } + else + { + error_jump('删除失败!请重新提交'); + } + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 49a8145..df6521d 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -93,20 +93,28 @@ class UserController extends CommonController public function add() { - return view('admin.user.add'); - } - - public function doadd() - { - unset($_POST["_token"]); - if(DB::table('user')->insert($_POST)) + if(Helper::isPostRequest()) { - success_jump('添加成功!', route('admin_user')); + unset($_POST["_token"]); + + if(DB::table('user')->where('user_name', $_POST["user_name"])->first()){error_jump('用户名已经存在');} + if(DB::table('user')->where('mobile', $_POST["mobile"])->first()){error_jump('手机号已经存在');} + $_POST['password'] = md5($_POST['password']); + $_POST['add_time'] = time(); + + if(DB::table('user')->insert($_POST)) + { + success_jump('添加成功!', route('admin_user')); + } + else + { + error_jump('添加失败!请修改后重新添加'); + } } - else - { - error_jump('添加失败!请修改后重新添加'); - } + + $data['user_rank'] = DB::table('user_rank')->orderBy('rank', 'asc')->get(); + + return view('admin.user.add',$data); } public function edit() diff --git a/app/Http/Controllers/Admin/UserRankController.php b/app/Http/Controllers/Admin/UserRankController.php index b20a4e2..30cd2c8 100644 --- a/app/Http/Controllers/Admin/UserRankController.php +++ b/app/Http/Controllers/Admin/UserRankController.php @@ -35,9 +35,12 @@ class UserRankController extends CommonController if(isset($_POST['editorValue'])){unset($_POST['editorValue']);} unset($_POST["_token"]); + if(DB::table('user_rank')->where('rank', $_POST["rank"])->first()){error_jump('等级已经存在');} + if(DB::table('user_rank')->where('title', $_POST["title"])->first()){error_jump('等级名称已经存在');} + if(DB::table('user_rank')->insert(array_filter($_POST))) { - success_jump('添加成功!', route('admin_slide')); + success_jump('添加成功!', route('admin_userrank')); } else { @@ -57,9 +60,12 @@ class UserRankController extends CommonController if(isset($_POST['editorValue'])){unset($_POST['editorValue']);} unset($_POST["_token"]); - if(DB::table('user_rank')->where('id', $id)->update($_POST)) + if(DB::table('user_rank')->where(['rank'=>$_POST["rank"],'id'=>['<>',$id]])->first()){error_jump('等级已经存在');} + if(DB::table('user_rank')->where(['title'=>$_POST["title"],'id'=>['<>',$id]])->first()){error_jump('等级名称已经存在');} + + if(DB::table('user_rank')->where('id', $id)->update($_POST) !== false) { - success_jump('修改成功!', route('admin_slide')); + success_jump('修改成功!', route('admin_userrank')); } else { diff --git a/app/Http/Model/Kuaidi.php b/app/Http/Model/Kuaidi.php new file mode 100644 index 0000000..4279ce8 --- /dev/null +++ b/app/Http/Model/Kuaidi.php @@ -0,0 +1,30 @@ +快递列表 > 添加快递 + +
+ +@endsection \ No newline at end of file diff --git a/resources/views/admin/bonus/edit.blade.php b/resources/views/admin/bonus/edit.blade.php new file mode 100644 index 0000000..b24c8ba --- /dev/null +++ b/resources/views/admin/bonus/edit.blade.php @@ -0,0 +1,79 @@ +@extends('admin.layouts.app') +@section('title', '快递修改') + +@section('content') +