/** * Store a newly created resource in storage. * POST /participant * * @return Response */ public function store($id) { $user = Auth::user(); $club = $user->Clubs()->FirstOrFail(); $event = Evento::Find($id); $player = Player::Find(Input::get('player')); $uuid = Uuid::generate(); $input = Input::all(); $messages = array('player.required' => 'Please select at least one player'); $validator = Validator::make(Input::all(), Participant::$rules, $messages); $validator->sometimes(array('fee', 'early_fee', 'early_deadline'), 'required', function ($input) { return $input->fee != ''; }); $validator->sometimes(array('fee', 'early_fee', 'early_deadline'), 'required', function ($input) { return $input->early_fee != ''; }); $validator->sometimes(array('fee', 'early_fee', 'early_deadline'), 'required', function ($input) { return $input->early_deadline != ''; }); $validator->sometimes(array('fee', 'early_fee', 'early_deadline'), 'required', function ($input) { return $input->plan_id != ''; }); if (empty(Input::get('fee'))) { $fee = $event->getOriginal('fee'); } else { $fee = Input::get('fee'); } if (empty(Input::get('early_fee'))) { $early_fee = $event->getOriginal('early_fee'); } else { $early_fee = Input::get('early_fee'); } if (empty(Input::get('early_deadline'))) { $early_deadline = $event->early_due_deadline; } else { $early_deadline = Input::get('early_deadline'); } if (empty(Input::get('plan_id'))) { $plan_id = $event->plan_id; } else { $plan_id = Input::get('plan_id'); } if (Input::get('fee') == '0') { $fee = 0; $plan_id = null; } if (Input::get('fee') > 0) { $plan_id = Input::get('plan_id'); } if ($validator->passes()) { $participant = new Participant(); $participant->id = $uuid; $participant->firstname = $player->firstname; $participant->lastname = $player->lastname; $participant->due = $fee; $participant->early_due = $early_fee; $participant->early_due_deadline = $early_deadline; $participant->plan_id = $plan_id; $participant->player_id = $player->id; $participant->event_id = $event->id; $status = $participant->save(); if ($status) { $participant = Participant::find($uuid); //send email notification of acceptance $data = array('club' => $club, 'player' => $player, 'user' => $user, 'participant' => $participant); $mail = Mail::send('emails.notification.event.invite', $data, function ($message) use($user, $club, $participant) { $message->from('*****@*****.**', 'C2C Lacrosse')->to($participant->player->user->email, $participant->accepted_by)->subject("You're Invited to join our event | " . $club->name); }); return Redirect::action('EventoController@show', $event->id)->with('notice', 'Player added successfully'); } else { $error = $status->errors()->all(':message'); return Redirect::back()->withInput()->withErrors($error); } } $error = $validator->errors()->all(':message'); return Redirect::back()->withInput()->withErrors($error); }
public function PaymentRemoveCartItem($club, $id) { $club = Club::Find($club); $event = Evento::Find($id); // Clean the cart Cart::destroy(); return Redirect::action('ClubPublicController@selectPlayer', array($club->id, $event->id)); }