Esempio n. 1
1
 /**
  * Remove the specified resource from storage.
  *
  * @param  string $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $social_media = $this->social_medias->find($id);
     $social_media->delete();
     flash()->info('Deleted', 'Social Media has been deleted');
     return redirect()->route('admin.social_media.index');
 }
Esempio n. 2
0
 /**
  * Update the specified resource in storage.
  *
  * @param UserRequest $request
  * @param User $user
  * @return Response
  */
 public function update(UserRequest $request, User $user)
 {
     $user->update($request->all());
     $user->uploadAndSave();
     flash()->success("User has been successfully updated!");
     return redirect()->back()->withInput();
 }
Esempio n. 3
0
 /**
  * Removes the specified user from the specified role.
  *
  * @param int|string $roleId
  * @param int|string $userId
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy($roleId, $userId)
 {
     $this->authorize('admin.roles.users.destroy');
     $role = $this->role->findOrFail($roleId);
     $user = $role->users()->findOrFail($userId);
     // Retrieve the administrators name.
     $adminName = Role::getAdministratorName();
     // Retrieve all administrators.
     $administrators = $this->user->whereHas('roles', function ($query) use($adminName) {
         $query->whereName($adminName);
     })->get();
     $admin = Role::whereName($adminName)->first();
     // We need to verify that if the user is trying to remove all roles on themselves,
     // and they are the only administrator, that we throw an exception notifying them
     // that they can't do that. Though we want to allow the user to remove the
     // administrator role if more than one administrator exists.
     if ($user->hasRole($admin) && $user->id === auth()->user()->id && count($administrators) === 1) {
         flash()->setTimer(null)->error('Error!', "Unable to remove the administrator role from this user. You're the only administrator.");
         return redirect()->route('admin.roles.show', [$roleId]);
     }
     if ($role->users()->detach($user)) {
         flash()->success('Success!', 'Successfully removed user.');
         return redirect()->route('admin.roles.show', [$roleId]);
     }
     flash()->error('Error!', 'There was an issue removing this user. Please try again.');
     return redirect()->route('admin.roles.show', [$roleId]);
 }
 public function destroy(ConsumablesMinimumLevel $consumables_minimum_levels)
 {
     $this->authorize('edit_consumable_minimum_levels');
     $consumables_minimum_levels->delete();
     flash()->success('Consumables Minimum Level Deleted', 'The consumables minimum level has been removed');
     return redirect()->action('ConsumablesMinimumLevelsController@index');
 }
 public function destroy($id)
 {
     $user = $this->model->findOrFail($id);
     $this->userRepository->deleteUser($user);
     flash()->success(trans('LaravelAdmin::laravel-admin.userDeleted'));
     return Redirect::back();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $project = Project::findOrFail($id);
     $project->delete();
     flash('Your Project Was Deleted Successfully');
     return redirect()->back();
 }
Esempio n. 7
0
 private function modify($user, $message)
 {
     $user->requested_new_role = false;
     $user->save();
     flash()->success($user->name . " " . $message);
     return redirect()->route('role.index');
 }
 /**
  * Handle permissions change
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function putAll(Request $request)
 {
     $permissions = Permission::all();
     $input = array_keys($request->input('permissions'));
     try {
         DB::beginTransaction();
         $permissions->each(function ($permission) use($input) {
             if (in_array($permission->id, $input)) {
                 $permission->allow = true;
             } else {
                 $permission->allow = false;
             }
             $permission->save();
         });
         DB::commit();
         flash()->success(trans('permissions.save_success'));
     } catch (\Exception $e) {
         var_dump($e->getMessage());
         die;
         flash()->error(trans('permissions.save_error'));
     }
     try {
         Cache::tags(['permissions'])->flush();
     } catch (\Exception $e) {
         Cache::flush();
     }
     return redirect()->back();
 }
Esempio n. 9
0
 /**
  * @param Requests\CreateArticleRequest $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function store(ArticleRequest $request)
 {
     //validation
     $this->createArticle($request);
     flash("Your post has been successful")->important();
     return redirect('articles');
 }
Esempio n. 10
0
 function actionReturn($code)
 {
     $url = "https://github.com/login/oauth/access_token?client_id=" . $this->app_key . "&redirect_uri=" . urlencode($this->url) . "&client_secret=" . $this->app_secret . "&code=" . $_GET['code'] . "";
     $content = file_get_contents($url);
     $s = $content;
     $s = explode('&', $s);
     $d = explode('=', $s[0]);
     $access_token = $d[1];
     if ($access_token) {
         try {
             $this->auth = OAuth2::provider($this->type, array('id' => $this->app_key, 'secret' => $this->app_secret));
             $token = Token::factory('access', array('access_token' => $access_token));
             $info = $this->auth->get_user_info($token);
             $uid = $info['uid'];
             $me['id'] = $uid;
             $me['name'] = $info['name'];
             $me['email'] = $info['emial'];
             $r = $this->member_get_third_set_user($me, $this->oauth_id, $access_token);
             flash('success', __('login success'));
             $this->redirect(return_url());
         } catch (OAuthException $e) {
             flash('error', __('login error'));
             $this->redirect(return_url());
         }
     }
     exit;
 }
Esempio n. 11
0
 /**
  * Update the business service types.
  *
  * @param Business $business
  * @param Request  $request
  *
  * @return Response
  */
 public function update(Business $business, Request $request)
 {
     logger()->info(__METHOD__);
     logger()->info(sprintf('businessId:%s', $business->id));
     $this->authorize('manageServices', $business);
     // BEGIN
     $servicetypeSheet = $request->input('servicetypes');
     $regex = '/(?P<name>[a-zA-Z\\d\\-\\ ]+)\\:(?P<description>[a-zA-Z\\d\\ ]+)/im';
     preg_match_all($regex, $servicetypeSheet, $matches, PREG_SET_ORDER);
     $publishing = collect($matches)->map(function ($item) {
         $data = array_only($item, ['name', 'description']);
         $data['slug'] = str_slug($data['name']);
         return $data;
     });
     foreach ($business->servicetypes as $servicetype) {
         if (!$this->isPublished($servicetype, $publishing)) {
             $servicetype->delete();
         }
     }
     foreach ($publishing as $servicetypeData) {
         $servicetype = ServiceType::firstOrNew($servicetypeData);
         $business->servicetypes()->save($servicetype);
     }
     flash()->success(trans('servicetype.msg.update.success'));
     return redirect()->route('manager.business.service.index', [$business]);
 }
Esempio n. 12
0
 public function deletePreset(Request $request)
 {
     $id = $request->id;
     $preset = RecordPreset::where('id', '=', $id)->first();
     $preset->delete();
     flash()->overlay('Record has been removed as a preset.', 'Success!');
 }
Esempio n. 13
0
 public function permissionsDelete($id, $permission)
 {
     $role = $this->model->findOrFail($id);
     $role->perms()->detach($permission);
     flash()->success(trans('LaravelAdmin::laravel-admin.permissionsDetachedSuccess'));
     return Redirect::back();
 }
Esempio n. 14
0
 public function update($id, Requests\BrandRequest $request)
 {
     $brand = Brand::findOrFail($id);
     $brand->update(['name' => $request->get('name'), 'code' => $request->get('code')]);
     flash()->success('Brand has been updated.');
     return redirect('brands');
 }
Esempio n. 15
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(ModuleRequest $request, $id)
 {
     $module = Module::findOrFail($id);
     $module->update($request->all());
     flash()->success(trans('all.module_edited'));
     return redirect(action('Admin\\ModulesController@index'));
 }
Esempio n. 16
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  FlyerRequest  $request
  * @return Response
  */
 public function store(FlyerRequest $request)
 {
     $flyer = $this->user->publish(new Flyer($request->all()));
     flash()->success('Success', 'Your flyer has been created!');
     return redirect(flyer_path($flyer));
     //temporary
 }
Esempio n. 17
0
 public function updateEdition(Request $request, $bookId, $editionId)
 {
     $edition = Edition::findOrFail($editionId);
     $edition->update($request->all());
     flash()->success('Updated', 'Edition has been updated');
     return redirect("/admin/books/{$bookId}/editions");
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $comment = Comment::findOrFail($id);
     $comment->delete();
     flash()->success('Success', "Comment deleted successfully");
     return redirect()->back();
 }
Esempio n. 19
0
 public function postReceive()
 {
     $code = Input::get('code');
     if ($code) {
         $coupon = AdminCoupon::where(['coupon_code' => $code])->first();
         if ($coupon) {
             $data = [];
             $data['coupon_id'] = $coupon->id;
             $data['user_id'] = Session::get('uid');
             $data['is_used'] = 0;
             $isCoupon = PhoneUserToCoupon::where($data)->first();
             if ($isCoupon) {
                 flash('亲,您已经领取过这个红包啦~');
                 return redirect()->back();
             }
             $couponToUser = new PhoneUserToCoupon();
             $couponToUser->coupon_id = $coupon->id;
             $couponToUser->user_id = Session::get('uid');
             if ($couponToUser->save()) {
                 $coupon->used += 1;
                 $coupon->save();
                 return redirect("coupon/success/{$coupon->coupon_price}");
             } else {
                 flash('亲~现在服务器压力山大~请稍后再试');
                 return redirect()->back();
             }
         } else {
             flash('亲~兑换码不对呦~请重试');
             return redirect()->back();
         }
     } else {
         flash('亲~兑换码不能为空哦~请重试');
         return redirect()->back();
     }
 }
Esempio n. 20
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array $data
  * @return User
  */
 protected function create(array $data)
 {
     $user = User::create(['first_name' => $data['first_name'], 'second_name' => $data['second_name'], 'email' => $data['email'], 'verify_token' => str_random(60), 'password' => bcrypt($data['password'])]);
     flash()->success('success', 'You are now logged in');
     $user->roles()->attach(1);
     return $user;
 }
Esempio n. 21
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $client = Client::findOrFail($id);
     $client->delete();
     flash()->success('Client Deleted!');
     return redirect()->route('clients.index');
 }
Esempio n. 22
0
 public function update(Request $request, $id)
 {
     $this->validate($request, ['name' => 'required', 'lastname' => 'required', 'password' => 'required|min:6', 'email' => 'required|email']);
     $user = User::find($id)->first();
     if ($request->file('edit-user-photo')) {
         $this->validate($request, ['edit-user-photo' => 'required|image|mimes:jpeg,jpg,png,bmp,gif,svg']);
         $userFile = $user->avatar_path . $user->avatar;
         if (\File::isFile($userFile)) {
             \File::delete($userFile);
         }
         $file = $request->file('edit-user-photo');
         $avatar_path = $this->_user_photo_path;
         $avatar = $file->getClientOriginalName();
         $file->move($avatar_path, $avatar);
         $user->avatar = $avatar;
         $user->avatar_path = $avatar_path;
     }
     $user->name = $request->get('name');
     $user->lastname = $request->get('lastname');
     $user->email = $request->get('email');
     $user->password = bcrypt($request->get('password'));
     $user->save();
     flash()->success('', 'Redaguotas!');
     return redirect()->back();
 }
 public static function destroy($id)
 {
     $hospital = Hospital::find($id);
     $hospital->destroy();
     flash('Hospital removed successfully!');
     Redirect::to('/hospitals');
 }
Esempio n. 24
0
 public function deleteClass($id)
 {
     $deleteClass = User_classes::find($id);
     $deleteClass->delete();
     flash()->success('Your class has been deleted.');
     return redirect('/');
 }
Esempio n. 25
0
 public function putContent(Request $request)
 {
     $contents = $request->all();
     $file = Storage::put('filter.txt', $contents['keywords']);
     flash()->success('修改成功');
     return redirect()->back();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  FlyerRequest  $request
  * @return Response
  */
 public function store(FlyerRequest $request)
 {
     $flyer = $this->user->publish(new Flyer($request->all()));
     // flash messaging
     flash('Success!', 'Your flyer has been created!');
     return redirect(flyer_path($flyers));
 }
Esempio n. 27
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $message = null;
     if ($this->validator($request->all())->fails()) {
         flash()->error('Please fill all the required field!');
         return redirect()->back()->withInput();
     }
     if ($this->user->email) {
         $employee = $this->user->employee;
         $sender = ['email' => $this->user->email, 'name' => $employee ? $employee->fullName() : $this->user->username];
         $recipient = $request->recipient;
         $message = Mail::raw($request->content, function ($msg) use($request, $sender) {
             $msg->from($sender['email'], $sender['name']);
             $msg->to($request->recipient);
             $msg->subject($request->subject);
             $request->cc ? $message->cc($request->cc) : null;
             $request->bcc ? $message->cc($request->bcc) : null;
         });
     }
     if ($message) {
         flash()->success('Message successfully sent!');
     } else {
         flash()->error('Message not sent!');
     }
     return redirect()->back();
 }
Esempio n. 28
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(FlyerRequest $request)
 {
     // Flyer::create($request->all(), Auth::user()->name);
     $flyer = $this->user->publish(new Flyer($request->all()));
     flash()->success('Flyer Created', 'Your flyer has been created.');
     return redirect(flyer_path($flyer));
 }
 public static function destroy($id)
 {
     $role = Role::find($id);
     $role->destroy();
     flash('Role removed successfully!');
     Redirect::to('/roles');
 }
Esempio n. 30
0
 /**
  * Update the specified User in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     // return $request->input();
     $utente = $this->dispatchFrom('Ibi\\Commands\\InternalUsers\\UpdateInternalUserCommand', $request);
     flash()->success('News aggiornata correttamente.');
     return redirect()->to('/admin/utenti');
 }