dyjh 6 jaren geleden
bovenliggende
commit
c607452cef

+ 8 - 2
app/Http/Controllers/Admin/Album/UserController.php

xqd
@@ -159,8 +159,14 @@ class UserController extends Controller
     }
 
     public function role(Request $request){
-        $user = AlbumUserModel::find(request('id'));
-        $user->role = request('role');
+        $id = request('id');
+        $role = request('role');
+        $user = AlbumUserModel::find($id);
+        if ($role == 4) {
+            $user->is_boss = 1;
+        } else {
+            $user->role = $role;
+        }
         $ok = $user->save();
         if($ok) {
             return $this->showMessage('操作成功');

+ 11 - 11
app/Http/Controllers/Api/V1/AlbumBossController.php

xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd
@@ -68,7 +68,7 @@ class AlbumBossController extends Controller
             'store_id.required' => '缺少商户参数',
         ]);
 
-        if ($userAuth->role != 4) {
+        if ($userAuth->is_boss != 1) {
             return $this->error(ErrorCode::NOT_BOSS, '该用户没有Boss权限');
         }
 
@@ -149,7 +149,7 @@ class AlbumBossController extends Controller
             'pageNum.required' => '缺少页码参数',
         ]);
 
-        if ($userAuth->role != 4) {
+        if ($userAuth->is_boss != 1) {
             return $this->error(ErrorCode::NOT_BOSS, '该用户没有Boss权限');
         }
 
@@ -245,7 +245,7 @@ class AlbumBossController extends Controller
             'agent_id.required' => '缺少经销商参数',
         ]);
 
-        if ($userAuth->role != 4) {
+        if ($userAuth->is_boss != 1) {
             return $this->error(ErrorCode::NOT_BOSS, '该用户没有Boss权限');
         }
 
@@ -353,7 +353,7 @@ class AlbumBossController extends Controller
             'store_id.required' => '缺少商户参数',
         ]);
 
-        if ($userAuth->role != 4) {
+        if ($userAuth->is_boss != 1) {
             return $this->error(ErrorCode::NOT_BOSS, '该用户没有Boss权限');
         }
 
@@ -430,7 +430,7 @@ class AlbumBossController extends Controller
             'store_id.required' => '缺少商户参数',
         ]);
 
-        if ($userAuth->role != 4) {
+        if ($userAuth->is_boss != 1) {
             return $this->error(ErrorCode::NOT_BOSS, '该用户没有Boss权限');
         }
 
@@ -528,7 +528,7 @@ class AlbumBossController extends Controller
             'store_id.required' => '缺少商户参数',
         ]);
 
-        if ($userAuth->role != 4) {
+        if ($userAuth->is_boss != 1) {
             return $this->error(ErrorCode::NOT_BOSS, '该用户没有Boss权限');
         }
 
@@ -598,7 +598,7 @@ class AlbumBossController extends Controller
             'store_id.required' => '缺少商户参数',
         ]);
 
-        if ($userAuth->role != 4) {
+        if ($userAuth->is_boss != 1) {
             return $this->error(ErrorCode::NOT_BOSS, '该用户没有Boss权限');
         }
 
@@ -680,7 +680,7 @@ class AlbumBossController extends Controller
             'store_id.required' => '缺少商户参数',
         ]);
 
-        if ($userAuth->role != 4) {
+        if ($userAuth->is_boss != 1) {
             return $this->error(ErrorCode::NOT_BOSS, '该用户没有Boss权限');
         }
 
@@ -770,7 +770,7 @@ class AlbumBossController extends Controller
             'store_id.required' => '缺少商户参数',
         ]);
 
-        if ($userAuth->role != 4) {
+        if ($userAuth->is_boss != 1) {
             return $this->error(ErrorCode::NOT_BOSS, '该用户没有Boss权限');
         }
 
@@ -848,7 +848,7 @@ class AlbumBossController extends Controller
         ], [
             'store_id.required' => '缺少商户参数',
         ]);
-        if ($userAuth->role != 4) {
+        if ($userAuth->is_boss != 1) {
             return $this->error(ErrorCode::NOT_BOSS, '该用户没有Boss权限');
         }
         if ($validator->fails()) {
@@ -908,7 +908,7 @@ class AlbumBossController extends Controller
         ], [
             'store_id.required' => '缺少商户参数',
         ]);
-        if ($userAuth->role != 4) {
+        if ($userAuth->is_boss != 1) {
             return $this->error(ErrorCode::NOT_BOSS, '该用户没有Boss权限');
         }
 

+ 5 - 1
app/Http/Controllers/Api/V1/AlbumController.php

xqd
@@ -249,7 +249,11 @@ class AlbumController extends Controller
             }
             $userAuth->save();
             $user['up_agent_id'] = $userAuth->up_agent_id;
-            $user['role'] = $userAuth->role;
+            if ($userAuth->is_boss == 1) {
+                $user['role'] = 4;
+            } else {
+                $user['role'] = 0;
+            }
             if (!file_exists(public_path() . '/base/poster/avatar/' . $datas['store_id'])) {
                 mkdir(public_path() . '/base/poster/avatar/' . $datas['store_id'], 0755, true);
             }

+ 1 - 0
app/Models/AlbumUserModel.php

xqd
@@ -49,6 +49,7 @@ class AlbumUserModel extends Authenticatable
         'avatar',
         'store_id',
         'is_dealer',
+        'is_boss',
         'phone',
         'role'
     ];

+ 33 - 0
database/migrations/2019_05_17_132117_add_is_boss_to_album_user.php

xqd
@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddIsBossToAlbumUser extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('album_user', function (Blueprint $table) {
+            //
+            $table->unsignedInteger('is_boss')->nullable()->default(0);
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('album_user', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 1 - 1
resources/views/admin/album/agent/index.blade.php

xqd
@@ -64,7 +64,7 @@
 								<td>
 									<div class="pull-left">
 										@if(role('Album/User/role-boss'))
-											@if($item->role !== 4)
+											@if($item->is_boss !== 1)
 												<a href="{{ U('Album/User/role',['id'=>$item->user_id,'role'=>4]) }}" class="btn btn-sm btn-default pull-right">设为Boss
 												</a>
 											@endif