public function postTicket() { //require login if (!Auth::check()) { return Redirect::to("auth/login"); } //auth check passed $ticket = new Ticket(); //this ticket should be associated with nobody when it is first created. $ticket->assigned_to = null; $ticket->setStatus($ticket->getStatusFromFriendly('new')); $ticket->priority = 2; $ticket->date_created = Carbon::now(); $ticket->placedBy()->associate(Auth::user()); $ticket->subject = Input::get("ticketTitle"); $ticket->save(); //add a message containing the ticket text $message = new Message(); $message->user()->associate(Auth::user()); $message->ticket()->associate($ticket); $message->text = Input::get("ticketText"); $message->ticket_status = $ticket->status; $message->created = Carbon::now(); $message->save(); //now show the ticket return view('helpdesk/ticket', compact("ticket")); }