浏览代码

add job department project verification

GGican 8 年之前
父节点
当前提交
a9b9b943aa

+ 5 - 15
app/Http/Controllers/Admin/DepartmentController.php

xqd xqd xqd
@@ -2,6 +2,7 @@
 
 namespace App\Http\Controllers\Admin;
 
+use App\Http\Requests\DepartmentRequest;
 use App\Model\Adminuser;
 use App\Model\Department;
 use App\Model\Job;
@@ -39,10 +40,10 @@ class DepartmentController extends CommonController
 
     }
 
-    public function update($dep_id)
+    public function update(DepartmentRequest $request, $dep_id)
     {
 
-        if (!Department::where('id', $dep_id)->update(Input::except('_token', '_method'))) return back()->withErrors('机构信息更新失败,请稍后重试!');
+        if (!Department::where('id', $dep_id)->update($request->except('_token', '_method'))) return back()->withErrors('机构信息更新失败,请稍后重试!');
 
         return redirect('/department');
 
@@ -57,24 +58,13 @@ class DepartmentController extends CommonController
 
     }
 
-    public function store()
+    public function store(DepartmentRequest $request)
     {
 
-        $input = Input::except('_token');
+        $input = $request->except('_token');
 
         $input['display'] = '1';
 
-        $validator = Validator::make($input, [
-            'department_description' => 'max:200',
-            'department_name' => 'required|max:100',
-        ], [
-            'department_name.required' => '名称不能为空!',
-            'department_description.max' => '描述不能超过100字!',
-            'department_name.max' => '名称请保持在50字内!',
-        ]);
-
-        if ($validator->fails()) return back()->withErrors($validator);
-
         if (!Department::create($input)) return back()->withErrors('新建失败,请稍后重试!');
 
         return redirect('/department');

+ 6 - 4
app/Http/Controllers/Admin/JobController.php

xqd xqd xqd xqd
@@ -2,6 +2,7 @@
 
 namespace App\Http\Controllers\Admin;
 
+use App\Http\Requests\JobRequest;
 use App\Model\Adminuser;
 use App\Model\Job;
 use App\Model\Tablelist;
@@ -10,6 +11,7 @@ use Illuminate\Support\Facades\Input;
 use Illuminate\Support\Facades\Validator;
 use App\Http\Controllers\Admin\CommonController;
 use Session;
+use Symfony\Component\HttpFoundation\Request;
 
 class JobController extends CommonController
 {
@@ -38,10 +40,10 @@ class JobController extends CommonController
 
     }
 
-    public function update($job_id)
+    public function update(JobRequest $request,$job_id)
     {
 
-        if (!Job::where('id', $job_id)->update(Input::except('_token', '_method'))) return back()->with('errors', '职位信息更新失败,请稍后重试!');
+        if (!Job::where('id', $job_id)->update($request->except('_token', '_method'))) return back()->with('errors', '职位信息更新失败,请稍后重试!');
 
         return redirect('/job');
 
@@ -56,9 +58,9 @@ class JobController extends CommonController
 
     }
 
-    public function store()
+    public function store(JobRequest $request)
     {
-        $input = Input::except('_token');
+        $input = $request->except('_token');
 
         $input['display'] = '1';
 

+ 5 - 4
app/Http/Controllers/Admin/ProjectController.php

xqd xqd xqd
@@ -2,6 +2,7 @@
 
 namespace App\Http\Controllers\Admin;
 
+use App\Http\Requests\ProjectRequest;
 use App\Http\Requests\Request;
 use App\Model\Project;
 use App\Model\Tablelist;
@@ -39,9 +40,9 @@ class ProjectController extends CommonController
 
     }
 
-    public function update($project_id)
+    public function update(ProjectRequest $request,$project_id)
     {
-        $input = Input::except('_token', '_method');
+        $input = $request->except('_token', '_method');
 
         if (!Project::where('id', $project_id)->update($input)) return back()->with('errors', '更新失败,请检查输入后重试!');
 
@@ -76,10 +77,10 @@ class ProjectController extends CommonController
 
     }
 
-    public function store()
+    public function store(ProjectRequest $request)
     {
 
-        $input = Input::except('_token');
+        $input = $request->except('_token');
 
         $input['display'] = 1;
 

+ 39 - 0
app/Http/Requests/DepartmentRequest.php

xqd
@@ -0,0 +1,39 @@
+<?php
+
+namespace App\Http\Requests;
+
+use App\Http\Requests\Request;
+
+class DepartmentRequest extends Request
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return true;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        return [
+            'department_name'=>'required',
+            'department_description' => 'max:200',
+        ];
+    }
+
+    public function messages()
+    {
+        return [
+            'department_name.required'=>'机构名称不能为空',
+            'department_description.max' => '描述不能超过100字!',
+        ];
+    }
+}

+ 37 - 0
app/Http/Requests/JobRequest.php

xqd
@@ -0,0 +1,37 @@
+<?php
+
+namespace App\Http\Requests;
+
+use App\Http\Requests\Request;
+
+class JobRequest extends Request
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return true;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        return [
+            'display_name'=>'required',
+        ];
+    }
+
+    public function messages()
+    {
+        return [
+            'display_name.required'=>'职位名称不能为空!',
+        ];
+    }
+}

+ 37 - 0
app/Http/Requests/ProjectRequest.php

xqd
@@ -0,0 +1,37 @@
+<?php
+
+namespace App\Http\Requests;
+
+use App\Http\Requests\Request;
+
+class ProjectRequest extends Request
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return true;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        return [
+            'project_name'=>'required',
+        ];
+    }
+
+    public function messages()
+    {
+        return [
+            'project_name.required'=>'项目名称不能为空!',
+        ];
+    }
+}

+ 10 - 1
resources/views/admin/job/create.blade.php

xqd
@@ -41,7 +41,16 @@
                             <label class="col-sm-3 control-label">职位权限</label>
 
                             <div class="col-sm-6">
-                                <input type="text" class="form-control" name="role" value="" placeholder="0 - 6,数字越大权限越高">
+                                <select name="role" class="form-control">
+                                    <option value="0">0 - 6,数字越大权限越高</option>
+                                    <option value="0">0</option>
+                                    <option value="1">1</option>
+                                    <option value="2">2</option>
+                                    <option value="3">3</option>
+                                    <option value="4">4</option>
+                                    <option value="5">5</option>
+                                    <option value="6">6</option>
+                                </select>
                             </div>
                         </div>