public function update_roles(Request $request) { #acl work to check if the user is allowed to perform the updation #--------- extract the name of the file $path_parts = pathinfo($_SERVER['REQUEST_URI']); $resource_name = $path_parts['filename']; #--------- get the id of the role $resource_id = Resources::where('name', $resource_name)->first(); #--------- get the user's privilegeid $user_type_id = \Auth::user()->privilegesid; #--------- get operationid from privileges where rolesid and resourceid match $get_info = array(); $get_info = Privileges::where('rolesid', $user_type_id)->where('resourceid', $resource_id->id)->get(); #--------- get id of update from operations table $update_id = Operations::where('actions', 'update')->first(); #--------giving $value a default value $value = ""; #-------- forecah loop for matching the data foreach ($get_info as $info) { if ($info->operationid == $update_id->id) { $value = "yes"; } } #--------checking if $value is empty or not if ($value != "") { //===========================acl completed $username = $request->update; $reassign = $request->reassign; #-------query to get the id $type_id = DB::table('roles')->where('type', $reassign)->first(); #-------query to update the user's table for the respective user DB::table('users')->where('name', $username)->update(['privilegesid' => $type_id->id]); return Redirect::to('roles')->with('message_for_roles', 'Successful update!'); } else { return Redirect::to('roles')->with('message_for_roles', 'Extremely sorry you dont have permissions!'); } }
public function update_data(Request $request) { $checked = $request->checked; $role = $request->role; $resource_info = $request->resource_info; $action_id = $request->action_id; if ($checked == 'true') { $data = new Privileges(); $data->rolesid = $role; $data->resourceid = $resource_info; $data->operationid = $action_id; $data->save(); } else { $delete_row = Privileges::where('rolesid', $role)->where('resourceid', $resource_info)->where('operationid', $action_id)->delete(); } $str = array(); $str['u'] = "success"; return response()->json($str); }
<ul class="treeview-menu"> <?php foreach ($child as $keychild) { if (sizeof(\App\Privileges::where('id_koperasi', Auth::user()->assigned_koperasi)->where('id_users', Auth::user()->id)->where('id_menu', $keychild->id)->get()) > 0) { $menus = \App\Menu::find($keychild->id); $child = \App\Menu::where('id_induk', $keychild->id)->get(); ?> <li class="treeview"> <a href="{{url($menus->url)}}"><i class="fa {!!$menus->icon!!}"></i> {{$menus->nama}} {!!(sizeof($child)>0)?'<i class="fa fa-angle-left pull-right"></i>':""!!}</a> <?php if (sizeof($child) > 0) { ?> <ul class="treeview-menu"> <?php foreach ($child as $keychild) { if (sizeof(\App\Privileges::where('id_koperasi', Auth::user()->assigned_koperasi)->where('id_users', Auth::user()->id)->where('id_menu', $keychild->id)->get()) > 0) { $menus = \App\Menu::find($keychild->id); $child = \App\Menu::where('id_induk', $keychild->id)->get(); ?> <li class="treeview"> <a href="{{url($menus->url)}}"><i class="fa {!!$menus->icon!!}"></i> {{$menus->nama}} {!!(sizeof($child)>0)?'<i class="fa fa-angle-left pull-right"></i>':""!!}</a> <?php if (sizeof($child) > 0) { ?> <ul class="treeview-menu"> <?php foreach ($child as $keychild) { ?> <li><a href="{{url($keychild->url)}}"><i class="fa {{$keychild->icon}}"></i> {{$keychild->nama}}</a></li> <?php
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { \App\User::where('assigned_koperasi', Auth::user()->assigned_koperasi)->find($id)->delete(); \App\Privileges::where('id_koperasi', Auth::user()->assigned_koperasi)->where('id_users', $id)->delete(); return redirect(url('pengaturan/pengurus')); }