瀏覽代碼

role permission

GGican 8 年之前
父節點
當前提交
e401de41f4

+ 7 - 2
app/Http/Controllers/Admin/CommonController.php

xqd
@@ -2,9 +2,14 @@
  namespace App\Http\Controllers\Admin;
 
  use App\Http\Controllers\Controller;
-
+ use Illuminate\Support\Facades\View;
+ use Illuminate\Support\Facades\Session;
  class CommonController extends Controller{
 
-
+  public function __construct()
+  {
+   $user = session('user');
+    View::share('user',$user);
+  }
 
  }

+ 1 - 0
app/Http/Controllers/Admin/IndexController.php

xqd
@@ -12,6 +12,7 @@ namespace App\Http\Controllers\Admin;
         public function index()
         {
             $data = Tablelist::where('status','>','5')->orderby('id','asc')->paginate(10);
+
             return view('admin.index',compact('data'));
         }
 

+ 1 - 5
app/Http/Controllers/Admin/TableController.php

xqd
@@ -173,11 +173,7 @@ class TableController extends CommonController
         $table = json_decode($table,true);
         $table = array_merge($table,$json);
         $user = session('user');
-        if($user->role>5){
-            $table['judge']=6;
-        }else{
-            $table['judge']=0;
-        }
+        $table['judge']=$user->role;
         $table = (object)$table;
 
         if($table_type_id == 1){

+ 4 - 2
resources/views/admin/index.blade.php

xqd
@@ -137,8 +137,10 @@
                                         <td>{{ $list->used }}</td>
                                         <td><a href="{{ url('/table/'.$list->id.'/edit') }}" class="btn btn-primary btn-sm">
                                                 <i class="fa fa-search"></i> 查看</a>
-                                            <a href="{{ url('/table/'.$list->id.'/edit') }}" class="btn btn-success btn-sm">
-                                                <i class="fa fa-pencil"></i> 编辑</a>
+                                            @if($user->role>5)
+                                                <a href="{{ url('/table/'.$list->id.'/edit') }}" class="btn btn-success btn-sm">
+                                                    <i class="fa fa-pencil"></i> 编辑</a>
+                                                @endif
                                         </td>
                                     </tr>
                                         @endforeach