Ejemplo n.º 1
1
 /**
  *  get_show takes in a username, finds the user's id from the username, gets the information about the user from the 
  *	followers and critts table and outputs it into the others.profile view
  */
 public function action_show($username)
 {
     // we get the user's id that matches the username
     $user_id = User::where('username', '=', $username)->only('id');
     // declare some default values for variables
     $following = null;
     $followers = 0;
     // if the username is not found, display an error
     if ($user_id == null) {
         echo "This username does not exist.";
     } else {
         if (Auth::user()) {
             // if the user tries to go to his/her own profile, redirect to user's profile action.
             if ($user_id == Auth::user()->id) {
                 return Redirect::to_action('user@index');
             }
             // check if the current user is already following $username
             $following = Follower::where('user_id', '=', Auth::user()->id)->where('following_id', '=', $user_id)->get() ? true : false;
         }
         // eager load the critts with user data
         $allcritts = Critt::with('user')->where('user_id', '=', $user_id);
         // order the critts and split them in chunks of 10 per page
         $critts = $allcritts->order_by('created_at', 'desc')->paginate(10);
         // count the critts
         $critts_count = $allcritts->count();
         // count the followers
         $followers = Follower::where('following_id', '=', $user_id)->count();
         // bind data to the view
         return View::make('others.profile')->with('username', $username)->with('user_id', $user_id)->with('following', $following)->with('followers', $followers)->with('count', $critts_count)->with('critts', $critts);
     }
 }
Ejemplo n.º 2
0
 /**
  *	post_unfollow is called when the "Unfollow" button is pressed on another user's profile, 
  *	deleting a relationship in the DB
  */
 public function post_unfollow()
 {
     $following_id = Input::get('id');
     $follower_id = Auth::user()->id;
     Follower::where('user_id', '=', $follower_id)->where('following_id', '=', $following_id)->delete();
     return Redirect::back();
 }
 public function vaultUpdate($id)
 {
     $user = Auth::user();
     $follow = Follower::where("user_id", "=", $user->id)->FirstOrFail();
     $club = Club::find($follow->club_id);
     $validator = Validator::make(Input::all(), Payment::$rules);
     if ($validator->passes()) {
         //validation done prior ajax
         $param = array('customer_vault_id' => $id, 'club' => $club->id, 'ccnumber' => Input::get('card'), 'ccexp' => sprintf('%02s', Input::get('month')) . Input::get('year'), 'cvv' => Input::get('cvv'), 'address1' => Input::get('address'), 'city' => Input::get('city'), 'state' => Input::get('state'), 'zip' => Input::get('zip'));
         $payment = new Payment();
         $transaction = $payment->update_customer($param, $user);
         if ($transaction->response == 3 || $transaction->response == 2) {
             $data = array('success' => false, 'error' => $transaction);
             return $data;
         } else {
             //update user customer #
             $user->profile->customer_vault = $transaction->customer_vault_id;
             $user->profile->save();
             //retrived data save from API - See API documentation
             $data = array('success' => true, 'customer' => $transaction->customer_vault_id, 'card' => substr($param['ccnumber'], -4), 'ccexp' => $param['ccexp'], 'zip' => $param['zip']);
             return Redirect::action('AccountController@settings')->with('notice', 'Payment information updated successfully');
         }
     }
     return Redirect::back()->withErrors($validator)->withInput();
     return Redirect::action('AccountController@settings');
 }
 /**
  * Show the form for creating a new resource.
  * GET /player/create
  *
  * @return Response
  */
 public function create()
 {
     $user = Auth::user();
     $follow = Follower::where("user_id", "=", $user->id)->FirstOrFail();
     $club = Club::find($follow->club_id);
     $title = 'League Together - Player';
     return View::make('app.account.player.create')->with('page_title', $title)->with('club', $club)->withUser($user);
 }
 private function checkUnique()
 {
     $query = Follower::where('event_id', $this->getEvent())->where('user_id', $this->getUser())->first();
     if (!$query) {
         return $this->setEvent($this->getEvent());
     } else {
         return $this->checkUnique();
     }
 }
 /**
  * Display a listing of the resource.
  * GET /follower
  *
  * @return Response
  */
 public function index()
 {
     $user = Auth::user();
     $club = $user->Clubs()->FirstOrFail();
     $followers = Follower::where('club_id', '=', $club->id)->get();
     $players = [];
     //get player from follower
     foreach ($followers as $follower) {
         $fuser = User::find($follower->user_id);
         if ($fuser->players) {
             foreach (User::find($follower->user_id)->players as $data) {
                 $data['fullname'] = "{$data->firstname} {$data->lastname}";
                 $data['username'] = "******";
                 $data['useremail'] = "{$fuser->email}";
                 $players[] = $data;
             }
         }
     }
     $title = 'League Together - ' . $club->name . ' Followers';
     return View::make('app.club.follower.index')->with('page_title', $title)->with('club', $club)->with('followers', $followers)->with('players', $players)->withUser($user);
 }
 public function PaymentStore($id)
 {
     $user = Auth::user();
     $participant = Participant::find($id);
     $title = 'League Together - ' . $participant->event->club->name . ' Teams';
     $player = $participant->player;
     $club = $participant->event->club;
     $cart = Cart::contents(true);
     $uuid = Uuid::generate();
     //Addition for stub feature
     $follow = Follower::where("user_id", "=", $user->id)->FirstOrFail();
     //check if follower equal club
     if ($follow->club_id != $club->id) {
         $param = array('ccnumber' => str_replace('_', '', Input::get('card')), 'ccexp' => sprintf('%02s', Input::get('month')) . Input::get('year'), 'cvv' => Input::get('cvv'), 'address1' => Input::get('address'), 'city' => Input::get('city'), 'state' => Input::get('state'), 'zip' => Input::get('zip'), 'discount' => Input::get('discount'), 'club' => $club->id, 'firstname' => $user->profile->firstname, 'lastname' => $user->profile->lastname, 'phone' => $user->profile->mobile);
     } else {
         $param = array('customer_vault_id' => $user->profile->customer_vault, 'discount' => Input::get('discount'), 'club' => $club->id);
     }
     $payment = new Payment();
     $transaction = $payment->sale($param);
     if ($transaction->response == 3 || $transaction->response == 2) {
         return Redirect::action('ParticipantController@paymentCreate', array($participant->id))->with('error', $transaction->responsetext);
     } else {
         foreach (Cart::contents() as $item) {
             $payment->id = $uuid;
             $payment->customer = $user->profile->customer_vault;
             $payment->transaction = $transaction->transactionid;
             $payment->subtotal = $transaction->subtotal;
             $payment->service_fee = $transaction->fee;
             $payment->total = $transaction->total;
             $payment->promo = $transaction->promo;
             $payment->tax = $transaction->tax;
             $payment->discount = $transaction->discount;
             $payment->club_id = $club->id;
             $payment->user_id = $user->id;
             $payment->player_id = $item->player_id;
             $payment->event_type = $participant->event->type_id;
             $payment->type = $transaction->type;
             $payment->save();
             $salesfee = $item->price / getenv("SV_FEE") - $item->price;
             $sale = new Item();
             $sale->description = $item->name;
             $sale->quantity = $item->quantity;
             $sale->price = $item->price;
             $sale->fee = $salesfee;
             $sale->participant_id = $participant->id;
             $sale->payment_id = $uuid;
             $sale->event_id = $participant->event->id;
             $sale->save();
             $participant->accepted_on = Carbon::Now();
             $participant->accepted_by = $user->profile->firstname . ' ' . $user->profile->lastname;
             $participant->accepted_user = $user->id;
             $participant->method = $item->type;
             $participant->status = 1;
             $participant->save();
             //create payments plan schedule
             if ($item->type == "plan") {
                 $subtotal = $participant->plan->getOriginal('recurring');
                 $fee = $subtotal / getenv("SV_FEE") - $subtotal;
                 $total = $fee + $subtotal;
                 for ($x = 1; $x < $participant->plan->recurrences + 1; $x++) {
                     $today = Carbon::now();
                     $today->addMonths($x);
                     $payon = $participant->plan->getOriginal('on');
                     //make sure the payday is a valid day
                     if ($payon == 31) {
                         if ($today->month == 2) {
                             $payon = 28;
                         }
                         if ($today->month == 4 || $today->month == 6 || $today->month == 9 || $today->month == 11) {
                             $payon = 30;
                         }
                     }
                     $payday = Carbon::create($today->year, $today->month, $payon, 0);
                     $schedule = new SchedulePayment();
                     $schedule->date = $payday;
                     $schedule->description = "Membership Team " . $participant->event->name;
                     $schedule->subtotal = number_format($subtotal, 2);
                     $schedule->fee = number_format($fee, 2);
                     $schedule->total = number_format($total, 2);
                     $schedule->plan_id = $participant->plan->id;
                     $schedule->club_id = $club->id;
                     $schedule->participant_id = $participant->id;
                     $status = $schedule->save();
                     if (!$status) {
                         return "We process your payment but and error occurred in the process, please contact us: support@leaguetogether.com Error# 597";
                     }
                 }
                 //end for loop
             }
             //end if plan
         }
         //email receipt
         $payment->receipt($transaction, $club->id, $item->player_id);
         $data = array('club' => $club, 'player' => $player, 'user' => $user, 'participant' => $participant);
         $mail = Mail::send('emails.notification.event.accept', $data, function ($message) use($user, $club, $participant) {
             $message->from('*****@*****.**', 'C2C Lacrosse')->to($user->email, $participant->accepted_by)->subject("Thank you for joining our event | " . $club->name);
             foreach ($club->users()->get() as $value) {
                 $message->bcc($value->email, $club->name);
             }
         });
         return Redirect::action('ParticipantController@paymentSuccess', array($participant->id))->with('result', $transaction);
     }
 }
 /**
  * Show the form for editing the specified resource.
  * GET /contact/{id}/edit
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $user = Auth::user();
     $follow = Follower::where("user_id", "=", $user->id)->FirstOrFail();
     $club = Club::find($follow->club_id);
     $players = $user->players;
     $contact = Contact::find($id);
     $title = 'League Together - Player';
     return View::make('app.account.contact.edit')->with('page_title', $title)->with('players', $players->lists('firstname', 'id'))->with('club', $club)->with('contact', $contact)->withUser($user);
 }
 public function PaymentStoreTeam($club, $id)
 {
     $user = Auth::user();
     $team = Team::find($id);
     $club = Club::find($club);
     $cart = Cart::contents(true);
     $uuid = Uuid::generate();
     $uuidMember = Uuid::generate();
     //Addition for stub feature
     $follow = Follower::where("user_id", "=", $user->id)->FirstOrFail();
     $title = 'League Together - ' . $team->club->name . ' Teams';
     //check if follower equal club
     if ($follow->club_id != $club->id) {
         $param = array('ccnumber' => str_replace('_', '', Input::get('card')), 'ccexp' => sprintf('%02s', Input::get('month')) . Input::get('year'), 'cvv' => Input::get('cvv'), 'address1' => Input::get('address'), 'city' => Input::get('city'), 'state' => Input::get('state'), 'zip' => Input::get('zip'), 'discount' => Input::get('discount'), 'club' => $club->id, 'firstname' => $user->profile->firstname, 'lastname' => $user->profile->lastname, 'phone' => $user->profile->mobile);
     } else {
         $param = array('customer_vault_id' => $user->profile->customer_vault, 'discount' => Input::get('discount'), 'club' => $club->id);
     }
     $payment = new Payment();
     $transaction = $payment->sale($param);
     if ($transaction->response == 3 || $transaction->response == 2) {
         return Redirect::action('ClubPublicController@PaymentCreateTeam', array($club->id, $team->id))->with('error', $transaction->responsetext);
     } else {
         foreach (Cart::contents() as $item) {
             $player = Player::find($item->player_id);
             //default from team
             $due = $team->getOriginal('due');
             $early_due = $team->getOriginal('early_due');
             $early_due_deadline = $team->getOriginal('early_due_deadline');
             $member = new Member();
             $member->id = $uuidMember;
             $member->firstname = $player->firstname;
             $member->lastname = $player->lastname;
             $member->due = $due;
             $member->early_due = $early_due;
             $member->early_due_deadline = $early_due_deadline;
             $member->plan_id = $team->plan_id;
             $member->player_id = $player->id;
             $member->team_id = $item->team_id;
             $member->accepted_on = Carbon::Now();
             $member->accepted_by = $user->profile->firstname . ' ' . $user->profile->lastname;
             $member->accepted_user = $user->id;
             $member->method = $item->type;
             $member->status = 1;
             $member->save();
             $payment->id = $uuid;
             $payment->customer = $user->profile->customer_vault;
             $payment->transaction = $transaction->transactionid;
             $payment->subtotal = $transaction->subtotal;
             $payment->service_fee = $transaction->fee;
             $payment->total = $transaction->total;
             $payment->promo = $transaction->promo;
             $payment->tax = $transaction->tax;
             $payment->discount = $transaction->discount;
             $payment->club_id = $club->id;
             $payment->user_id = $user->id;
             $payment->player_id = $item->player_id;
             $payment->event_type = null;
             $payment->type = $transaction->type;
             $payment->save();
             $salesfee = $item->price / getenv("SV_FEE") - $item->price;
             $sale = new Item();
             $sale->description = $item->name;
             $sale->quantity = $item->quantity;
             $sale->price = $item->price;
             $sale->fee = $salesfee;
             $sale->member_id = $uuidMember;
             $sale->team_id = $item->team_id;
             $sale->payment_id = $uuid;
             $sale->save();
             $member = Member::find($uuidMember);
             //create payments plan schedule
             if ($item->type == "plan") {
                 $subtotal = $member->plan->getOriginal('recurring');
                 $fee = $subtotal / getenv("SV_FEE") - $subtotal;
                 $total = $fee + $subtotal;
                 for ($x = 1; $x < $member->plan->recurrences + 1; $x++) {
                     $today = Carbon::now();
                     $today->addMonths($x);
                     $payon = $member->plan->getOriginal('on');
                     //make sure the payday is a valid day
                     if ($payon == 31) {
                         if ($today->month == 2) {
                             $payon = 28;
                         }
                         if ($today->month == 4 || $today->month == 6 || $today->month == 9 || $today->month == 11) {
                             $payon = 30;
                         }
                     }
                     $payday = Carbon::create($today->year, $today->month, $payon, 0);
                     $schedule = new SchedulePayment();
                     $schedule->date = $payday;
                     $schedule->description = "Membership Team " . $member->team->name;
                     $schedule->subtotal = number_format($subtotal, 2);
                     $schedule->fee = number_format($fee, 2);
                     $schedule->total = number_format($total, 2);
                     $schedule->plan_id = $member->plan->id;
                     $schedule->club_id = $club->id;
                     $schedule->member_id = $member->id;
                     $status = $schedule->save();
                     if (!$status) {
                         return "We process your payment but and error occurred in the process, please contact us: support@leaguetogether.com Error# 597";
                     }
                 }
                 //end for loop
             }
             //end if plan
             //waitlist process
             if ($team->max < $team->members->count()) {
                 //add to waitlist
                 $waitlist = new Waitlist();
                 $waitlist->id = Uuid::generate();
                 $waitlist->member_id = $uuidMember;
                 $waitlist->team_id = $team->id;
                 $waitlist->save();
             }
             if ($club->processor_name == 'Bluepay') {
                 //return Redirect::action('ClubPublicController@PaymentSuccessTeam', array($club->id, $team->id))->with('result','Success');
                 return Redirect::action('ClubPublicController@PaymentCreateTeam', array($club->id, $team->id))->with('error', 'Player added successfully.  Please check your email for receipt.');
             } else {
                 $payment->receipt($transaction, $club->id, $item->player_id);
                 return Redirect::action('ClubPublicController@PaymentSuccessTeam', array($club->id, $team->id))->with('result', $transaction);
             }
             //return Redirect::action('ClubPublicController@PaymentSuccessTeam', array($club->id, $team->id))->with('result',$transaction);
         }
     }
 }
 public function contactDelete($id, $contact)
 {
     $contact = Contact::find($contact);
     $user = Auth::user();
     $player = Player::find($id);
     $follow = Follower::where("user_id", "=", $player->user->id)->get();
     $club = $user->Clubs()->FirstOrFail();
     $title = 'League Together - Contact Delete';
     return View::make('app.club.contact.delete')->with('page_title', $title)->with('player', $player)->with('contact', $contact)->with('club', $club)->withUser($user);
 }