예제 #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(RoleRequest $request, $id)
 {
     $role = Role::findOrFail($id);
     $role->name = $request->get('name');
     $role->save();
     $role->syncPermission($request->get('permissions', []));
     \Notification::success('acl.roles.update.success');
     return redirect()->route('admin.roles.index');
 }
예제 #2
0
 /**
  * Method for stroring a new role in the database.
  *
  * @param RoleRequest $request
  * @return mixed
  */
 public function store(RoleRequest $request)
 {
     $role = new Role($request->all());
     $role->save();
     if (is_null($request->get('permissions'))) {
         $role->permissions()->sync([]);
     } else {
         $role->permissions()->sync($request->get('permissions'));
     }
     return redirect(route('rbac.roles.index'))->withSuccess('You have successfully created a new role.');
 }
예제 #3
0
 public function update($id, RoleRequest $request)
 {
     $this->role->save($id, $request->all());
     if ($request->ajax()) {
         return response()->json(['status' => trans('messages.saved'), 'type' => 'success']);
     }
     $route = $request->get('task') == 'apply' ? route('admin.roles.edit', $id) : route('admin.roles.index');
     return redirect($route)->with(['status' => trans('messages.saved'), 'type' => 'success']);
 }
예제 #4
0
 /**
  * Function Store
  * to Save/Update Brand From Brand Form
  * @Request @Name,@Code etc
  *
  * @return json
  */
 public function onStore(\App\Http\Requests\RoleRequest $request)
 {
     $is_exist = \App\Models\Role::where('name', $request->get('name'))->where('id', '!=', $request->get('id'))->get(['id'])->first();
     if ($is_exist) {
         $param['error'] = true;
         $param['message'] = Lang::get('message.role unique name');
         return json_encode($param);
     }
     $role = new \App\Models\Role();
     if ($request->has('id')) {
         $role = $role->where('id', $request->get('id'))->first();
         $role->updated_at = date('Y-m-d H:i:s');
         $role->updated_by = Auth::user()->id;
     } else {
         $role->created_at = date('Y-m-d H:i:s');
         $role->created_by = Auth::user()->id;
     }
     $role->name = $request->get('name');
     $role->description = $request->get('description');
     $role->active = $request->get('active') ? $request->get('active') : 0;
     $role->authorize = $request->get('authorize') ? $request->get('authorize') : 0;
     $role->save();
     $param['message'] = $request->get('id') ? Lang::get('info.updated') : Lang::get('info.inserted');
     $param['error'] = false;
     return json_encode($param);
 }