|
|
@ -5,25 +5,28 @@ namespace App\Http\Controllers; |
|
|
|
use Illuminate\Http\Request; |
|
|
|
use Illuminate\Http\Request; |
|
|
|
use App\Models\Menu; |
|
|
|
use App\Models\Menu; |
|
|
|
use App\Models\RoleMenu; |
|
|
|
use App\Models\RoleMenu; |
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Log; |
|
|
|
|
|
|
|
|
|
|
|
class RoleMenuController extends Controller |
|
|
|
class RoleMenuController extends Controller |
|
|
|
{ |
|
|
|
{ |
|
|
|
public function add(Request $request) |
|
|
|
public function add(Request $request) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->validate($request, [ |
|
|
|
$this->validate($request, [ |
|
|
|
'role_id' => 'required', |
|
|
|
'role_id.*' => 'required', |
|
|
|
'menu_id' => 'required', |
|
|
|
'menu_id.*' => 'required' |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
$data = $request->all(); |
|
|
|
$data = $request->all(); |
|
|
|
|
|
|
|
|
|
|
|
$data['created_by'] = $this->currentName; |
|
|
|
$countData = 0; |
|
|
|
|
|
|
|
foreach($data as $arrData) { |
|
|
|
$result = RoleMenu::create($data); |
|
|
|
$arrData['created_by'] = $this->currentName; |
|
|
|
|
|
|
|
$result = RoleMenu::create($arrData); |
|
|
|
if($result){ |
|
|
|
$countData++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if($result && $countData > 0) { |
|
|
|
return response()->json(['status'=>'success','message'=>'add data role menu successfully!','code'=>200], 200); |
|
|
|
return response()->json(['status'=>'success','message'=>'add data role menu successfully!','code'=>200], 200); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
return response()->json(['status'=>'failed','message'=>'add data role menu failed!','code'=>400], 400); |
|
|
|
return response()->json(['status'=>'failed','message'=>'add data role menu failed!','code'=>400], 400); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|