|
|
|
@ -5,25 +5,28 @@ namespace App\Http\Controllers;
|
|
|
|
|
use Illuminate\Http\Request; |
|
|
|
|
use App\Models\Menu; |
|
|
|
|
use App\Models\RoleMenu; |
|
|
|
|
use Illuminate\Support\Facades\Log; |
|
|
|
|
|
|
|
|
|
class RoleMenuController extends Controller |
|
|
|
|
{ |
|
|
|
|
public function add(Request $request) |
|
|
|
|
{ |
|
|
|
|
$this->validate($request, [ |
|
|
|
|
'role_id' => 'required', |
|
|
|
|
'menu_id' => 'required', |
|
|
|
|
'role_id.*' => 'required', |
|
|
|
|
'menu_id.*' => 'required' |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
$data = $request->all(); |
|
|
|
|
|
|
|
|
|
$data['created_by'] = $this->currentName; |
|
|
|
|
|
|
|
|
|
$result = RoleMenu::create($data); |
|
|
|
|
|
|
|
|
|
if($result){ |
|
|
|
|
$countData = 0; |
|
|
|
|
foreach($data as $arrData) { |
|
|
|
|
$arrData['created_by'] = $this->currentName; |
|
|
|
|
$result = RoleMenu::create($arrData); |
|
|
|
|
$countData++; |
|
|
|
|
} |
|
|
|
|
if($result && $countData > 0) { |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|