/** * Handle the event. * * @param SubscriptionPayment\FailedInsufficientFunds $event */ public function handle(SubscriptionPayment\FailedInsufficientFunds $event) { $user = $this->userRepository->getById($event->userId); $this->mailer->send('emails.sub-payment-failed', ['user' => $user], function ($m) use($user) { $m->to($user->email, $user->name)->subject('Your subscription payment failed'); }); }
public function run() { $today = new Carbon(); //Fetch and check over active users which have a status of leaving $users = User::paymentWarning()->get(); foreach ($users as $user) { /** @var $user \BB\Entities\User */ if ($user->subscription_expires->lt($today)) { //User has passed their expiry date echo $user->name . ' has a payment warning and has passed their expiry date' . PHP_EOL; //Check the actual expiry date //When did their last sub payment expire $paidUntil = MembershipPayments::lastUserPaymentExpires($user->id); //What grace period do they have - when should we give them to $cutOffDate = MembershipPayments::getSubGracePeriodDate($user->payment_method); //If the cut of date is greater than (sooner) than the last payment date "expire" them if ($paidUntil == false || $cutOffDate->subDays(2)->gt($paidUntil)) { //set the status to left and active to false $this->userRepository->memberLeft($user->id); echo $user->name . ' marked as having left' . PHP_EOL; } //an email will be sent by the user observer } else { echo $user->name . ' has a payment warning but is within their expiry date' . PHP_EOL; } } }
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'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $user = User::findWithPermission($id); $input = $request->only('rules_agreed', 'induction_completed'); $this->inductionValidator->validate($input); $this->userRepository->recordInductionCompleted($id); return \Redirect::route('account.show', [$user->id]); }
/** * Create the sub charge for each member, only do this for members with dates matching the supplied date * * @param Carbon $targetDate */ public function createSubscriptionCharges($targetDate) { $users = $this->userRepository->getBillableActive(); foreach ($users as $user) { if ($user->payment_day == $targetDate->day && !$this->subscriptionChargeRepository->chargeExists($user->id, $targetDate)) { $this->subscriptionChargeRepository->createCharge($user->id, $targetDate); } } }
/** * A sub charge has been rolled back as a payment failed * * @param integer $chargeId * @param integer $userId * @param Carbon $paymentDate * @param double $amount */ public function onPaymentFailure($chargeId, $userId, Carbon $paymentDate, $amount) { $paidUntil = MembershipPayments::lastUserPaymentExpires($userId); if ($paidUntil) { $user = $this->userRepository->getById($userId); /** @var $user \BB\Entities\User */ $user->extendMembership(null, $paidUntil); } else { \Log::info('Payment cancelled, expiry date rollback failed as there is no previous payment. User ID:' . $userId); } }
/** * Execute the console command. * * @return mixed */ public function handle() { $users = $this->userRepo->getAll(); $this->output->progressStart($users->count()); foreach ($users as $user) { $memberCreditService = \App::make('\\BB\\Services\\Credit'); $memberCreditService->setUserId($user->id); $memberCreditService->recalculate(); $this->output->progressAdvance(); } $this->output->progressFinish(); }
public function run() { $today = new Carbon(); //Fetch and check over active users which have a status of leaving $users = User::leaving()->notSpecialCase()->get(); foreach ($users as $user) { if ($user->subscription_expires->lt($today)) { //User has passed their expiry date //set the status to left and active to false $this->userRepository->memberLeft($user->id); //an email will be sent by the user observer } } }
private function recordDoorKeyPaymentId($userId, $paymentId) { /* @TODO: Verify payment amount is valid - this could have been changed */ $user = $this->userRepository->getById($userId); $user->key_deposit_payment_id = $paymentId; $user->save(); }
/** * Update the specified resource in storage. * * @param int $id * @return \Illuminate\Http\RedirectResponse */ public function update($id) { $user = User::findWithPermission($id); $input = \Input::only('given_name', 'family_name', 'email', 'secondary_email', 'password', 'phone', 'address.line_1', 'address.line_2', 'address.line_3', 'address.line_4', 'address.postcode', 'emergency_contact', 'profile_private'); $this->userForm->validate($input, $user->id); $this->userRepository->updateMember($id, $input, \Auth::user()->hasRole('admin')); \Notification::success('Details Updated'); return \Redirect::route('account.show', [$user->id]); }
/** * Show the form for editing the specified resource. * * @param string $equipmentId * @return Response */ public function edit($equipmentId) { $equipment = $this->equipmentRepository->findBySlug($equipmentId); $memberList = $this->userRepository->getAllAsDropdown(); $roleList = \BB\Entities\Role::lists('title', 'id'); //$roleList->prepend(null); //dd($roleList); return \View::make('equipment.edit')->with('equipment', $equipment)->with('memberList', $memberList)->with('roleList', $roleList->toArray())->with('ppeList', $this->ppeList); }
/** * 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); }
/** * Store a newly created resource in storage. * * @return \Illuminate\Http\RedirectResponse */ public function store($userId) { $confirm_params = array('resource_id' => \Request::get('resource_id'), 'resource_type' => \Request::get('resource_type'), 'resource_uri' => \Request::get('resource_uri'), 'signature' => \Request::get('signature')); // State is optional if (\Request::get('state')) { $confirm_params['state'] = \Request::get('state'); } $user = User::findWithPermission($userId); try { $confirmed_resource = $this->goCardless->confirmResource($confirm_params); } catch (\Exception $e) { \Notification::error($e->getMessage()); return \Redirect::route('account.show', $user->id); } if (strtolower($confirmed_resource->status) != 'active') { \Notification::error('Something went wrong, you can try again or get in contact'); return \Redirect::route('account.show', $user->id); } $this->userRepository->recordGoCardlessVariableDetails($user->id, $confirmed_resource->id); //all we need for a valid member is an active dd so make sure the user account is active $this->userRepository->ensureMembershipActive($user->id); return \Redirect::route('account.show', [$user->id]); }
/** * Update a payment * Change where the money goes by altering the original record or creating a secondary payment * * @param Request $request * @param int $paymentId * * @return Illuminate\Http\RedirectResponse * @throws NotImplementedException * @throws \BB\Exceptions\PaymentException */ public function update(Request $request, $paymentId) { $payment = $this->paymentRepository->getById($paymentId); switch ($request->get('change')) { case 'assign-unknown-to-user': $newUserId = $request->get('user_id'); try { $newUser = $this->userRepository->getById($newUserId); } catch (ModelNotFoundException $e) { \Notification::error('User not found'); break; } $this->paymentRepository->assignPaymentToUser($paymentId, $newUser->id); \Notification::success('Payment updated'); break; case 'refund-to-balance': $this->paymentRepository->refundPaymentToBalance($paymentId); \Notification::success('Payment updated'); break; default: throw new NotImplementedException('This hasn\'t been built yet'); } return \Redirect::back(); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $roles = Role::with('Users')->get(); $memberList = $this->userRepository->getAllAsDropdown(); return \View::make('roles.index')->with('roles', $roles)->with('memberList', $memberList); }
/** * Handle the event. * * @param SubscriptionChargePaid $event */ public function handle(SubscriptionChargePaid $event) { /** @var $user \BB\Entities\User */ $user = $this->userRepository->getById($event->subscriptionCharge->user_id); $user->extendMembership(null, $event->subscriptionCharge->payment_date->addMonth()); }
/** * @param mixed $userId */ public function setUserId($userId) { $this->userId = $userId; $this->user = $this->userRepository->getById($this->userId); }
public function index() { $users = $this->userRepository->getActivePublicList(!\Auth::guest()); return \View::make('members.index')->withUsers($users); }