/**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (empty($request->user()->is_admin)) {
         Flash::danger('You don\'t have permission to access this area.');
         return redirect('/login');
     }
     return $next($request);
 }
示例#2
0
 public function register(Request $request)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     Flash::success('You have been successfully registered at Lambda Phoenix Center');
     Auth::login($this->create($request->all()));
     return redirect($this->redirectPath());
 }
 public function postIncentives($plan, Request $request, Email $mailer)
 {
     $user = Auth::user();
     $user->brick_text = $request->get('brick_text');
     $user->tshirt_size = $request->get('tshirt_size');
     $user->save();
     $data = ['user' => $user, 'view' => 'emails.account.incentives', 'recipient' => env('MEMBERSHIP_EMAIL'), 'subject' => 'Member Incentives for ' . $user->first_name . ' ' . $user->last_name];
     $mailer->send($data);
     Flash::success('Your membership incentives were successfully requested. You will hear back from a Lambda Board member shortly.');
     return redirect('dashboard');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \App\Http\Requests\ContactRequest  $request
  * @param $mailer
  * @param $thankYou
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\ContactRequest $request, Email $mailer, ThankYouMailer $thankYou)
 {
     $data = ['name' => $request->get('first_name') . ' ' . $request->get('last_name'), 'email' => $request->get('email'), 'phone' => $request->get('phone'), 'recipients' => $request->get('recipients'), 'comments' => $request->get('comments'), 'subject' => 'Message From the Website', 'view' => 'emails.general.contact'];
     $mailer->send($data);
     $data['subject'] = 'Thank You For Contacting Lambda Phoenix Center';
     $data['view'] = 'emails.general.thank-you';
     unset($data['recipients']);
     $data['recipient'] = $request->get('email');
     $thankYou->thank($data);
     Flash::success('Your email was sent successfully. Please allow 2-3 days for a response.');
     return redirect()->home();
 }
示例#5
0
 public function password(Request $request, Email $mailer)
 {
     $password = str_random(8);
     $userId = $request->get('user_id');
     $user = User::findOrFail($userId);
     $user->password = Hash::make($password);
     $user->save();
     $data = ['password' => $password, 'recipient' => $user->email, 'view' => 'emails.general.temporary-password', 'subject' => 'Your Lambda Phoenix Center temporary password'];
     $mailer->send($data);
     Flash::success($user->first_name . ' ' . $user->last_name . ' has been sent a temporary password');
     return redirect('admin/membership');
 }
示例#6
0
 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     $prefix = !is_null($request->route()) ? $request->route()->getAction()['prefix'] : NULL;
     if ($e instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) {
         if ($prefix != '/api/v1') {
             Flash::danger('The resource you are looking for could not be found.');
             return response()->view('errors.404', array(), 404);
         } else {
             return response()->json(['error' => 'Resource not found'], 400);
         }
     }
     if ($e instanceof \App\Exceptions\LambdaException && getenv('APP_ENV') !== 'local') {
         Flash::danger('An error occurred: ' . $e->getMessage());
         Log::error($e->getPrevious());
         return redirect()->home();
     }
     if ($e instanceof \PDOException) {
         return response()->view('errors.500');
     }
     if ($request->wantsJson()) {
         // Define the response
         $response = ['errors' => 'Sorry, something went wrong.'];
         // If the app is in debug mode
         if (config('app.debug')) {
             // Add the exception class name, message and stack trace to response
             $response['exception'] = get_class($e);
             // Reflection might be better here
             $response['message'] = $e->getMessage();
             $response['trace'] = $e->getTrace();
         }
         // Default response of 400
         $status = 400;
         // If this exception is an instance of HttpException
         if ($this->isHttpException($e)) {
             // Grab the HTTP status code from the Exception
             $status = $e->getStatusCode();
         }
         // Return a JSON response with the response array and status code
         return response()->json($response, $status);
     }
     if ($e instanceof \Tymon\JWTAuth\Exceptions\TokenExpiredException) {
         return response()->json(['Token expired'], $e->getStatusCode());
     } else {
         if ($e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException) {
             return response()->json(['Token invalid'], $e->getStatusCode());
         }
     }
     return parent::render($request, $e);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $user = Auth::user();
     $user->first_name = $request->get('first_name');
     $user->last_name = $request->get('last_name');
     $user->email = $request->get('email');
     $user->phone_number = $request->get('phone');
     $user->street_address = $request->get('address1');
     $user->city = $request->get('city');
     $user->state = $request->get('state_province');
     $user->zip = $request->get('postal_code');
     $user->save();
     Flash::success('Your member details have been successfully updated.');
     return redirect('dashboard');
 }
示例#8
0
 public function subscribe(Request $request)
 {
     $this->validate($request, ['phone_number' => 'required']);
     Sms::create(['phone_number' => $request->get('phone_number')]);
     $client = new Services_Twilio(env('TWILIO_SID'), env('TWILIO_AUTH'));
     try {
         $sms = $client->account->messages->sendMessage('508-9-LAMBDA', $request->get('phone_number'), 'Thank you for subscribing to Lambda SMS at 508-9-LAMBDA. We\'ll keep you up to date. Text STOP to unsubscribe.');
         Flash::success('You have been successfully subscribed');
         return back();
     } catch (Services_Twilio_RestException $e) {
         Flash::danger($e->getMessage());
         return back();
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['title' => 'required', 'story' => 'required', 'date_expires' => 'required']);
     $article = Article::find($id);
     $article->title = $request->get('title');
     $article->story = $request->get('story');
     $article->page_id = 1;
     $article->date_expires = date('Y-m-d', strtotime($request->get('date_expires')));
     $article->screenshot = $request->get('screenshot');
     $article->flyer = $request->get('flyer');
     $article->save();
     Flash::success('Article updated successfully.');
     return redirect('admin/articles');
 }
 protected function getResetFailureResponse(Request $request, $response)
 {
     Flash::danger(trans($response));
     return redirect()->back()->withInput($request->only('email'));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $user = User::findOrFail($id);
     $user->delete();
     Flash::success('This member was successfully deleted.');
     return redirect('admin/membership');
 }
 public function postChangePlan(Request $request, StripeBilling $billing)
 {
     $customerId = Auth::user()->customer_id;
     $planChanged = false;
     if (!empty($customerId)) {
         $newPlan = MembershipPlan::where('slug', $request->get('membership_plan'))->firstOrFail();
         $planChanged = $billing->updatePlan($customerId, $newPlan->slug);
         $user = Auth::user();
         $user->plan_id = $newPlan->id;
         $user->save();
     }
     if ($planChanged) {
         Flash::success('Your plan was successfully changed. You have been billed at the new rate.');
     } else {
         Flash::danger('We have no card on file for you.');
     }
     return redirect('dashboard');
 }
示例#13
0
 public function users(Request $request)
 {
     //try {
     $role = Role::find($request->get('role_id'));
     $user = User::find($request->get('user_id'));
     $roleName = $role->role_slug;
     $user->assignRole($roleName);
     Flash::success('The role "' . $role->role_name . '" was successfully assigned to the user ' . $user->first_name . ' ' . $user->last_name);
     //} catch (\Exception $e) {
     //    Flash::danger('The relationship you specified already exists: ' . $e->getMessage());
     //}
     return back();
 }
示例#14
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $event = Event::findOrFail($id);
     $event->delete();
     Flash::success('The event has been successfully deleted.');
     return redirect('admin/events');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $permission = Permission::create(['permission_name' => $request->get('permission_name'), 'permission_slug' => $request->get('permission_slug')]);
     Flash::success('The role "' . $permission->permission_name . '"" was successfully created.');
     return back();
 }
 public function postDonate($type, Request $request, StripeBilling $billing, Email $mailer, ReceiptMailer $receipt)
 {
     $this->validate($request, ['first_name' => 'required', 'last_name' => 'required', 'email' => 'required|email', 'amount' => 'required|integer']);
     $amount = str_replace('$', '', $request->get('amount'));
     $amount = round($amount) * 100;
     try {
         $charge = $billing->donate(array('amount' => $amount, 'email' => $request->get('email'), 'stripe-token' => $request->get('stripe-token')));
     } catch (\Exception $e) {
         Flash::danger($e->getMessage());
         return redirect()->refresh();
     }
     if (!empty($charge['created'])) {
         if (empty($request->get('anonymous'))) {
             $data = ['charge_id' => $charge['id'], 'name' => $request->get('first_name') . ' ' . $request->get('last_name'), 'email' => $request->get('email'), 'company' => $request->get('company'), 'street_address' => $request->get('address1') . ' ' . $request->get('address2'), 'city' => $request->get('city'), 'state' => $request->get('state_province'), 'zip' => $request->get('postal_code'), 'amount' => $amount];
             Donation::create($data);
             $data['type'] = $type;
             $data['view'] = 'emails.donations.notification';
             $data['recipient'] = env('MEMBERSHIP_EMAIL');
             $data['subject'] = 'Donation from ' . $request->get('first_name') . ' ' . $request->get('last_name');
             $mailer->send($data);
             $receipt->sendDonationReceipt($data);
         }
     }
     Flash::success('Thank you for your generosity. You will receipt your receipt via email.');
     return redirect()->home();
 }