Ejemplo n.º 1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \App\Http\Requests\UserTypeRequest  $request
  * @param  UserType $type
  * @return \Illuminate\Http\Response
  */
 public function update(Requests\UserTypeRequest $request, UserType $type)
 {
     DB::transaction(function () use($request, $type) {
         $type->update($request->except('access'));
         $type->access()->delete();
         $access = [];
         foreach ($request->get('access') as $acc) {
             $access[] = new UserTypeAccess(['user_type_id' => $type->id, 'access_id' => $acc]);
         }
         $type->access()->saveMany($access);
     });
     return redirect(action('Admin\\UserTypesController@index'))->with('success', 'updated');
 }