public function store()
 {
     $rules = ['name' => 'required'];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     } else {
         if (Input::has('ticket_type_id')) {
             $id = Input::get('ticket_type_id');
             $ticketType = TicketTypeModel::find($id);
         } else {
             $ticketType = new TicketTypeModel();
         }
         $ticketType->company_id = Session::get('company_id');
         $ticketType->name = Input::get('name');
         $ticketType->save();
         $alert['msg'] = 'Ticket Type has been saved successfully';
         $alert['type'] = 'success';
         return Redirect::route('company.ticket-type')->with('alert', $alert);
     }
 }
Example #2
0
 protected function saveModel($event, $tickettype = false)
 {
     eerror_log(json_encode($event));
     $new_tickettype = false;
     if (Input::get('id')) {
         $tickettype = TicketType::find(Input::get('id'));
         eerror_log("a tickettype id was posted");
     }
     if (!$tickettype) {
         $tickettype = new TicketType();
         $new_tickettype = true;
     }
     $tickettype->events_id = $event->id;
     $tickettype->name = Input::get('name');
     $tickettype->num_available = Input::get('num_available');
     $tickettype->price = str_replace(',', '.', Input::get('price'));
     $tickettype->order = Input::get('order');
     if (!$new_tickettype) {
         $tickettype->update();
     } else {
         $tickettype->save();
     }
     return $tickettype;
 }