/**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $fob = KeyFob::findOrFail($id);
     $fob->markLost();
     \Notification::success("Key Fob marked as lost/broken");
     return \Redirect::route('account.show', $fob->user_id);
 }
Esempio n. 2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request)
 {
     $this->repository->update($request->only('name'), auth()->user()->getAuthIdentifier());
     $this->repository->updateProfile($request->except('_token'), auth()->user()->getAuthIdentifier());
     \Notification::success(trans('users.flash.profile_updated'));
     return redirect()->back();
 }
 /**
  * Start the creation of a new gocardless payment
  *   Details get posted into this method and the redirected to gocardless
  * @param $userId
  * @throws \BB\Exceptions\AuthenticationException
  * @throws \BB\Exceptions\FormValidationException
  * @throws \BB\Exceptions\NotImplementedException
  */
 public function store($userId)
 {
     User::findWithPermission($userId);
     $requestData = \Request::only(['reason', 'amount', 'return_path', 'stripeToken', 'ref']);
     $stripeToken = $requestData['stripeToken'];
     $amount = $requestData['amount'];
     $reason = $requestData['reason'];
     $returnPath = $requestData['return_path'];
     $ref = $requestData['ref'];
     try {
         $charge = Stripe_Charge::create(array("amount" => $amount, "currency" => "gbp", "card" => $stripeToken, "description" => $reason));
     } catch (\Exception $e) {
         \Log::error($e);
         if (\Request::wantsJson()) {
             return \Response::json(['error' => 'There was an error confirming your payment'], 400);
         }
         \Notification::error("There was an error confirming your payment");
         return \Redirect::to($returnPath);
     }
     //Replace the amount with the one from the charge, this prevents issues with variable tempering
     $amount = $charge->amount / 100;
     //Stripe don't provide us with the fee so this should be OK
     $fee = $amount * 0.024 + 0.2;
     $this->paymentRepository->recordPayment($reason, $userId, 'stripe', $charge->id, $amount, 'paid', $fee, $ref);
     if (\Request::wantsJson()) {
         return \Response::json(['message' => 'Payment made']);
     }
     \Notification::success("Payment made");
     return \Redirect::to($returnPath);
 }
Esempio n. 4
0
 public function update(UpdatePassword $request)
 {
     $user = auth()->user();
     $this->repository->updatePassword($request->get('password'), $user->id);
     \Notification::success(trans('users.flash.password_updated'));
     return redirect()->back();
 }
 public function update($userId)
 {
     //Verify the user can access this user record - we don't need the record just the auth check
     $user = User::findWithPermission($userId);
     $input = \Input::all();
     //Clear the profile photo field as this is handled separately below.
     unset($input['new_profile_photo']);
     if (empty($input['profile_photo_private'])) {
         $input['profile_photo_private'] = false;
     }
     //Trim all the data so some of the validation doesn't choke on spaces
     foreach ($input as $key => $value) {
         if (is_string($value)) {
             $input[$key] = trim($value);
         }
     }
     $this->profileValidator->validate($input, $userId);
     $this->profileRepo->update($userId, $input);
     if (\Input::file('new_profile_photo')) {
         try {
             $this->userImage->uploadPhoto($user->hash, \Input::file('new_profile_photo')->getRealPath(), true);
             $this->profileRepo->update($userId, ['new_profile_photo' => 1]);
             \Notification::success("Photo uploaded, it will be checked and appear shortly");
         } catch (\Exception $e) {
             \Log::error($e);
         }
     } else {
         \Notification::success("Profile Updated");
     }
     return \Redirect::route('members.show', $userId);
 }
 /**
  * Start the creation of a new balance payment
  *   Details get posted into this method
  * @param $userId
  * @throws \BB\Exceptions\AuthenticationException
  * @throws \BB\Exceptions\FormValidationException
  * @throws \BB\Exceptions\NotImplementedException
  */
 public function store($userId)
 {
     $user = User::findWithPermission($userId);
     $this->bbCredit->setUserId($user->id);
     $requestData = \Request::only(['reason', 'amount', 'return_path', 'ref']);
     $amount = $requestData['amount'] * 1 / 100;
     $reason = $requestData['reason'];
     $returnPath = $requestData['return_path'];
     $ref = $requestData['ref'];
     //Can the users balance go below 0
     $minimumBalance = $this->bbCredit->acceptableNegativeBalance($reason);
     //What is the users balance
     $userBalance = $this->bbCredit->getBalance();
     //With this payment will the users balance go to low?
     if ($userBalance - $amount < $minimumBalance) {
         if (\Request::wantsJson()) {
             return \Response::json(['error' => 'You don\'t have the money for this'], 400);
         }
         \Notification::error("You don't have the money for this");
         return \Redirect::to($returnPath);
     }
     //Everything looks gooc, create the payment
     $this->paymentRepository->recordPayment($reason, $userId, 'balance', '', $amount, 'paid', 0, $ref);
     //Update the users cached balance
     $this->bbCredit->recalculate();
     if (\Request::wantsJson()) {
         return \Response::json(['message' => 'Payment made']);
     }
     \Notification::success("Payment made");
     return \Redirect::to($returnPath);
 }
 public function update($logEntryId)
 {
     $reason = \Request::get('reason');
     if (!in_array($reason, ['training', 'testing'])) {
         throw new \BB\Exceptions\ValidationException("Not a valid reason");
     }
     $equipmentLog = $this->equipmentLogRepository->getById($logEntryId);
     /*
     if ($equipmentLog->user_id == \Auth::user()->id) {
         throw new \BB\Exceptions\ValidationException("You can't update your own record");
     }
     */
     if (!\Auth::user()->hasRole($equipmentLog->device) && !\Auth::user()->isAdmin()) {
         throw new \BB\Exceptions\ValidationException("You don't have permission to alter this record");
     }
     if (!empty($equipmentLog->reason)) {
         throw new \BB\Exceptions\ValidationException("Reason already set");
     }
     $billedStatus = $equipmentLog->billed;
     if ($equipmentLog->billed) {
         //the user has been billed, we need to undo this.
         $payments = $this->paymentRepository->getPaymentsByReference($equipmentLog->id . ':' . $equipmentLog->device);
         if ($payments->count() == 1) {
             $this->paymentRepository->delete($payments->first()->id);
             $billedStatus = false;
         } else {
             throw new \BB\Exceptions\ValidationException("Unable to locate related payment, please contact an admin");
         }
     }
     $this->equipmentLogRepository->update($logEntryId, ['reason' => $reason, 'billed' => $billedStatus]);
     \Notification::success("Record Updated");
     return \Redirect::back();
 }
 public function store()
 {
     $input = \Input::only('subject', 'message', 'send_to_all', 'recipient');
     $this->emailNotificationValidator->validate($input);
     //This is for admins only unless they are part of a group, then they have access to specific lists
     if (!\Auth::user()->isAdmin() && !\Auth::user()->hasRole('laser')) {
     }
     if ($input['send_to_all']) {
         if ($input['recipient'] == 'all') {
             if (!\Auth::user()->isAdmin()) {
                 throw new AuthenticationException("You don't have permission to send to this group");
             }
             $users = $this->userRepository->getActive();
         } else {
             if ($input['recipient'] == 'laser_induction_members') {
                 if (!\Auth::user()->hasRole('laser')) {
                     throw new AuthenticationException("You don't have permission to send to this group");
                 }
                 $users = $this->inductionRepository->getUsersForEquipment('laser');
             } else {
                 throw new NotImplementedException("Recipient not supported");
             }
         }
         foreach ($users as $user) {
             $notification = new UserMailer($user);
             $notification->sendNotificationEmail($input['subject'], nl2br($input['message']));
         }
     } else {
         //Just send to the current user
         $notification = new UserMailer(\Auth::user());
         $notification->sendNotificationEmail($input['subject'], nl2br($input['message']));
     }
     \Notification::success('Email Queued to Send');
     return \Redirect::route('notificationemail.create');
 }
Esempio n. 9
0
 public function cancelUpload()
 {
     if (unlink($this->uploadedFile["tmp_name"])) {
         Notification::success(1, 'File upload was canceled.');
         return true;
     } else {
         return false;
     }
 }
Esempio n. 10
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param Email $email
  * @param $token
  * @return \Illuminate\Http\Response
  */
 public function activate(Email $email, $token)
 {
     if ($email->activate($token, auth()->user())) {
         \Notification::success(trans('email::email.activation_success'));
     } else {
         \Notification::error(trans('email::email.activation_failed'));
     }
     return redirect($this->redirectPath());
 }
Esempio n. 11
0
 /**
  * Update the specified user in storage.
  *
  * @param  \Illuminate\Http\Request     $request
  * @param  \App\User                    $user
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, User $user)
 {
     $user->update($request->except('biography', 'contactDetails', 'address'));
     $user->biography()->updateOrCreate([], $request->biography);
     $user->contactDetails()->updateOrCreate([], $request->contactDetails);
     $user->profile()->updateOrCreate([], $request->profile);
     $user->address()->updateOrCreate([], $request->address);
     \Notification::success("Künstler erfolgreich aktualisiert.");
     return back();
 }
 /**
  * Action the admin approve requests
  *
  * @param $id
  *
  * @return mixed
  * @throws \BB\Exceptions\AuthenticationException
  */
 public function approve($id)
 {
     $user = User::findWithPermission($id, 'comms');
     if (\Input::has('inducted_by')) {
         $user->inducted_by = \Auth::id();
         $user->save();
         \Notification::success('Updated');
     }
     return \Redirect::route('account.induction.index');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param      $userId
  * @param  int $id
  * @throws \BB\Exceptions\NotImplementedException
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update($userId, $id)
 {
     $induction = Induction::findOrFail($id);
     if (\Input::get('mark_trained', false)) {
         $induction->trained = \Carbon\Carbon::now();
         $induction->trainer_user_id = \Input::get('trainer_user_id', false);
         $induction->save();
     } elseif (\Input::get('is_trainer', false)) {
         $induction->is_trainer = true;
         $induction->save();
     } else {
         throw new \BB\Exceptions\NotImplementedException();
     }
     \Notification::success("Updated");
     return \Redirect::route('account.show', $userId);
 }
 /**
  * Remove cash from the users balance
  *
  * @param $userId
  * @return mixed
  * @throws \BB\Exceptions\AuthenticationException
  * @throws \BB\Exceptions\InvalidDataException
  */
 public function destroy($userId)
 {
     $user = User::findWithPermission($userId);
     $this->bbCredit->setUserId($userId);
     $amount = \Request::get('amount');
     $returnPath = \Request::get('return_path');
     $ref = \Request::get('ref');
     $minimumBalance = $this->bbCredit->acceptableNegativeBalance('withdrawal');
     if ($user->cash_balance + $minimumBalance * 100 < $amount * 100) {
         \Notification::error("Not enough money");
         return \Redirect::to($returnPath);
     }
     $this->paymentRepository->recordPayment('withdrawal', $userId, 'balance', '', $amount, 'paid', 0, $ref);
     $this->bbCredit->recalculate();
     \Notification::success("Payment recorded");
     return \Redirect::to($returnPath);
 }
 public function post()
 {
     $contact = $this->contact->first();
     if (!is_null($contact)) {
         $id = $contact->id;
         $contact = $this->contact->find($id);
         $contact->phone = \Input::get('phone');
         $contact->email = \Input::get('email');
         $contact->address = \Input::get('address');
         $contact->map = json_encode(explode(',', trim(\Input::get('map'))));
         $contact->show = 1;
         $contact->save();
     } else {
         $data = array('phone' => \Input::get('phone'), 'email' => \Input::get('email'), 'address' => \Input::get('address'), 'map' => \Input::get('map'), 'show' => 1);
         $this->contact->create($data);
     }
     \Notification::success('Done !');
     return \Redirect::back();
 }
Esempio n. 16
0
 public function post_delete()
 {
     if (Input::has('user_id')) {
         $uid = Input::get('user_id');
         $user = CmsUser::find($uid);
         //CHECK IF USER EXISTS
         if (empty($user)) {
             Notification::error(LL('cms::alert.delete_user_error', CMSLANG), 2500);
             return Redirect::to_action('cms::user');
         } else {
             $user->delete();
             Notification::success(LL('cms::alert.delete_user_success', CMSLANG, array('user' => $user->username)), 1500);
             return Redirect::to_action('cms::user');
         }
     } else {
         Notification::error(LL('cms::alert.delete_user_error', CMSLANG), 1500);
         return Redirect::to_action('cms::user');
     }
 }
 public function post_delete()
 {
     if (Input::has('role_id')) {
         $rid = Input::get('role_id');
         $page = CmsPage::where_role_id($rid)->first();
         //CHECK IF ROLE STILL IN USE
         if (!empty($page)) {
             Notification::error(LL('cms::alert.delete_role_stillinuse_error', CMSLANG, array('page' => $page->name)), 2500);
             return Redirect::to_action('cms::role');
         } else {
             $role = CmsRole::find($rid);
             $role->delete();
             Notification::success(LL('cms::alert.delete_role_success', CMSLANG, array('role' => $role->name)), 1500);
             return Redirect::to_action('cms::role');
         }
     } else {
         Notification::error(LL('cms::alert.delete_role_error', CMSLANG), 1500);
         return Redirect::to_action('cms::page');
     }
 }
Esempio n. 18
0
 public function post_delete()
 {
     if (Input::has('gallery_id')) {
         $gid = Input::get('gallery_id');
         $gallery = CmsGallery::find($gid);
         //CHECK IF GALLERY EXISTS
         if (!empty($gallery)) {
             //DELETE FROM DB
             $gallery->files()->delete();
             $gallery->delete();
             Notification::success(LL('cms::alert.delete_gallery_success', CMSLANG, array('gallery' => $gallery->name)), 1500);
             return Redirect::to_action('cms::gallery');
         } else {
             Notification::error(LL('cms::alert.delete_gallery_error', CMSLANG), 2500);
             return Redirect::to_action('cms::gallery');
         }
     } else {
         Notification::error(LL('cms::alert.delete_gallery_error', CMSLANG), 1500);
         return Redirect::to_action('cms::gallery');
     }
 }
 public function post_delete()
 {
     if (Input::has('banner_id')) {
         $bid = Input::get('banner_id');
         $banner = CmsBanner::find($bid);
         //CHECK IF BANNER EXISTS
         if (!empty($banner)) {
             //DELETE FROM DB
             $banner->files()->delete();
             $banner->delete();
             Notification::success(LL('cms::alert.delete_banner_success', CMSLANG, array('banner' => $banner->name)), 1500);
             return Redirect::to_action('cms::banner');
         } else {
             Notification::error(LL('cms::alert.delete_banner_error', CMSLANG), 2500);
             return Redirect::to_action('cms::banner');
         }
     } else {
         Notification::error(LL('cms::alert.delete_banner_error', CMSLANG), 1500);
         return Redirect::to_action('cms::banner');
     }
 }
 public function post_delete()
 {
     if (Input::has('download_id')) {
         $did = Input::get('download_id');
         $download = CmsDownload::find($did);
         //CHECK IF DOWNLOAD EXISTS
         if (!empty($download)) {
             //DELETE FROM DB
             $download->files()->delete();
             $download->delete();
             Notification::success(LL('cms::alert.delete_download_success', CMSLANG, array('download' => $download->name)), 1500);
             return Redirect::to_action('cms::download');
         } else {
             Notification::error(LL('cms::alert.delete_download_error', CMSLANG), 2500);
             return Redirect::to_action('cms::download');
         }
     } else {
         Notification::error(LL('cms::alert.delete_download_error', CMSLANG), 1500);
         return Redirect::to_action('cms::download');
     }
 }
 /**
  * This is a basic method for recording a payment transfer between two people
  * This should not exist and the normal balance payment controller should be used
  * If any more work is needed here please take the time and move it over!
  *
  * @param Request $request
  * @param integer $userId
  *
  * @return mixed
  * @throws ValidationException
  * @throws AuthenticationException
  */
 public function recordTransfer(Request $request, $userId)
 {
     $user = User::findWithPermission($userId);
     $this->bbCredit->setUserId($user->id);
     $amount = $request->get('amount');
     $targetUserId = $request->get('target_user_id');
     $targetUser = $this->userRepository->getById($targetUserId);
     if ($targetUserId === $userId) {
         throw new ValidationException('Your\'e trying to send money to yourself, no!');
     }
     //What is the users balance
     $userBalance = $this->bbCredit->getBalance();
     //With this payment will the users balance go to low?
     if ($userBalance - $amount < 0) {
         \Notification::error("You don't have the money for this");
         return \Redirect::route('account.balance.index', $user->id);
     }
     $this->paymentRepository->recordBalanceTransfer($user->id, $targetUser->id, $amount);
     \Notification::success("Transfer made");
     return \Redirect::route('account.balance.index', $user->id);
 }
 /**
  * Handle a POST request to reset a user's password.
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse|null
  */
 public function postReset(Request $request)
 {
     $credentials = $request->only('email', 'password', 'password_confirmation', 'token');
     $validator = app('Illuminate\\Contracts\\Validation\\Factory')->make($credentials, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|min:8']);
     if ($validator->fails()) {
         throw new FormValidationException('Error', $validator->errors());
     }
     //We aren't using a confirm password box so this can be faked
     $credentials['password_confirmation'] = $credentials['password'];
     $response = Password::reset($credentials, function ($user, $password) {
         $user->password = $password;
         $user->save();
     });
     switch ($response) {
         case Password::PASSWORD_RESET:
             \Notification::success("Your password has been changed");
             return redirect()->home();
         default:
             \Notification::error(trans($response));
             return redirect()->back()->withInput();
     }
 }
 public function post_delete()
 {
     if (Input::has('tag_id')) {
         $tid = Input::get('tag_id');
         $tag = CmsTag::find($tid);
         //CHECK IF TAG EXISTS
         if (!empty($tag)) {
             $lang = $tag->lang;
             //DELETE FROM DB
             $tag->blogs()->delete();
             $tag->delete();
             Notification::success(LL('cms::alert.delete_tag_success', CMSLANG, array('tag' => $tag->name)), 1500);
             return Redirect::to_action('cms::tag', array($lang));
         } else {
             Notification::error(LL('cms::alert.delete_tag_error', CMSLANG), 2500);
             return Redirect::to_action('cms::tag', array($lang));
         }
     } else {
         Notification::error(LL('cms::alert.delete_gallery_error', CMSLANG), 1500);
         return Redirect::to_action('cms::tag', array($lang));
     }
 }
 public function delete($id)
 {
     $this->cate->delete($id);
     \Notification::success('DELETED !');
     return \Redirect::back();
 }
Esempio n. 25
0
 public function post_delete()
 {
     if (Input::has('blog_id')) {
         $bid = Input::get('blog_id');
         $blog = CmsBlog::find($bid);
         //CHECK IF BLOG EXISTS
         if (!empty($blog)) {
             //OK, DELETE
             $blog->pages()->delete();
             $blog->delete();
             Notification::success(LL('cms::alert.delete_blog_success', CMSLANG, array('blog' => $blog->name)), 2500);
             return Redirect::to_action('cms::blog', array($blog->lang));
         } else {
             Notification::error(LL('cms::alert.delete_blog_error', CMSLANG), 2500);
             return Redirect::to_action('cms::blog', array(LANG));
         }
     } else {
         Notification::error(LL('cms::alert.delete_blog_error', CMSLANG), 2500);
         return Redirect::to_action('cms::blog', array(LANG));
     }
 }
 public function updateSubscriptionAmount($id)
 {
     $amount = \Input::get('monthly_subscription');
     if ($amount < 5) {
         throw new ValidationException('The minimum subscription is 5 GBP');
     } elseif (!\Auth::user()->isAdmin() && $amount < 15) {
         throw new ValidationException('The minimum subscription is 15 GBP, please contact the trustees for a lower amount. trustees@buildbrighton.com');
     }
     $user = User::findWithPermission($id);
     $user->updateSubAmount(\Input::get('monthly_subscription'));
     \Notification::success('Details Updated');
     return \Redirect::route('account.show', [$user->id]);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy($id = null)
 {
     Auth::logout();
     \Notification::success('Logged Out');
     return redirect()->home();
 }
Esempio n. 28
0
 public function post_clone_element()
 {
     if (Input::has('page_id') and Input::has('element_id') and Input::has('newpage_id')) {
         $pid = Input::get('page_id');
         $nid = Input::get('newpage_id');
         $eid = Input::get('element_id');
         $now = date('Y-m-d H:i:s');
         if (Input::has('to_clone')) {
             //CREATE NEW ELEMENT
             //GET ELEMENT MODEL
             $element = CmsElement::find($eid);
             $new_element_attr = array('author_id' => AUTHORID, 'name' => $element->name, 'label' => $element->label, 'text' => $element->text, 'zone' => $element->zone, 'lang' => LANG, 'is_valid' => 0);
             $new_element = new CmsElement($new_element_attr);
             $page = CmsPage::find($nid);
             $page->elements()->insert($new_element);
         } else {
             //GET ELEMENT MODEL
             $element = CmsElement::find($eid);
             $clone_array = array('cmselement_id' => $eid, 'cmspage_id' => $nid, 'created_at' => $now, 'updated_at' => $now);
             DB::table('elements_pages')->insert($clone_array);
         }
         Notification::success(LL('cms::alert.clone_element_success', CMSLANG, array('element' => $element->name)), 1500);
         return Redirect::to_action('cms::page', array(LANG));
     } else {
         Notification::error(LL('cms::alert.clone_element_error', CMSLANG), 1500);
         return Redirect::to_action('cms::page', array(LANG));
     }
 }
 public function destroyPhoto($equipmentId, $photoId)
 {
     $equipment = $this->equipmentRepository->findBySlug($equipmentId);
     $photo = $equipment->photos[$photoId];
     $equipment->removePhoto($photoId);
     Storage::delete($equipment->getPhotoBasePath() . $photo['path']);
     \Notification::success("Image deleted");
     return \Redirect::route('equipment.edit', $equipmentId);
 }
Esempio n. 30
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($id)
 {
     $group = Sentry::findGroupById($id);
     $group->delete();
     Notification::success('Group was successfully deleted');
     return Redirect::action('App\\Controllers\\Admin\\GroupController@index');
 }