Exemplo n.º 1
0
 public function store(StoreRoleRequest $request)
 {
     $role = $this->role->create($request->all());
     if ($role->id) {
         flash()->success('发布成功');
     } else {
         flash()->error('发布失败');
     }
     return redirect()->back();
 }
Exemplo n.º 2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(StoreRoleRequest $request, $id)
 {
     // default roles cannot be changed
     if ($id < 4) {
         return \Redirect::route($this->view_idx)->with(['status' => 'System default roles cannot be changed!']);
     }
     // was there any change?
     $output = Role::find($id);
     if ($request->input('name') == $output->name) {
         return \Redirect::route($this->view_idx)->with(['status' => 'no change']);
     }
     // get this Role
     Role::where('id', $id)->update($request->except(['_method', '_token']));
     $message = 'Role with id "' . $id . '" updated';
     return \Redirect::route($this->view_idx)->with(['status' => $message]);
 }