Example #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     // Store created ticket
     $this->validate($request, ['subject' => 'required|string', 'content' => 'required|string']);
     Ticket::create(['user_id' => auth()->user()->id, 'subject' => $request->get('subject'), 'content' => $request->get('content')]);
     return redirect('/home')->with('success', 'Support ticket created!');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     Ticket::create(['title' => 'Ticket 1', 'user_id' => 1, 'project_id' => 1, 'priority' => 0.5, 'progress' => 0.4, 'est_time' => 1.2, 'status_id' => 1, 'severity_id' => 1, 'ticket_type_id' => 1, 'description' => $faker->text, 'assignee_id' => 2]);
     Ticket::create(['title' => 'Ticket 2', 'user_id' => 2, 'project_id' => 1, 'priority' => 0.4, 'progress' => 0.4, 'est_time' => 1.2, 'status_id' => 1, 'severity_id' => 1, 'ticket_type_id' => 1, 'description' => $faker->text, 'assignee_id' => 2]);
     Ticket::create(['title' => 'Ticket 3', 'user_id' => 2, 'project_id' => 1, 'priority' => 0.3, 'progress' => 0.4, 'est_time' => 1.2, 'status_id' => 1, 'severity_id' => 1, 'ticket_type_id' => 1, 'description' => $faker->text, 'assignee_id' => 2]);
     Ticket::create(['title' => 'Ticket 4', 'user_id' => 1, 'project_id' => 1, 'priority' => 0.3, 'progress' => 0.4, 'est_time' => 1.2, 'status_id' => 1, 'severity_id' => 1, 'ticket_type_id' => 1, 'description' => $faker->text, 'assignee_id' => 3]);
 }
Example #3
0
 public function create(Request $request)
 {
     $validator = Validator::make($request->all(), ['name' => 'required', 'email' => 'required|email', 'subject' => 'required', 'body' => 'required']);
     if ($validator->fails()) {
         return response($validator->errors(), 404);
     } else {
         $this->dispatch(new ZendeskTicketCreate(Ticket::create($request->all())->id));
         return response(['created' => true], 200);
     }
 }
 public function store($project_id)
 {
     $input = \Input::all();
     $input['ticket']['project_id'] = $project_id;
     $v = \Validator::make($input['ticket'], \App\Ticket::$createRules);
     if ($v->fails()) {
         return \Redirect::route('projects.tickets.create', ['project_id' => $project_id])->withErrors($v->errors())->withInput();
     }
     $ticket = \App\Ticket::create($input['ticket']);
     return \Redirect::route('projects.tickets.show', ['project_id' => $project_id, 'ticket_id' => $ticket->id]);
 }
Example #5
0
 public function update($id)
 {
     // save updated
     $record = $this->records->find($id);
     if (!$record) {
         Ticket::create(Input::all());
         return $this->respond($record);
     }
     $record->fill(Input::all())->save();
     return $this->respond($record);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     //In real world only authenticated users allowed to create resource
     //lets go with simple validation (we In real world we will have dedicted service for this)
     if (!$request->get('name') or !$request->get('email') or !$request->get('subject') or !$request->get('body')) {
         return $this->validationFails('Validation faild for ticket');
     }
     //Sometimes we return the new created resource
     //For now let go with status info only
     $ticket = Ticket::create(["name" => $request->input('name'), "email" => $request->input('email'), 'subject' => $request->input('subject'), 'body' => $request->input('body')]);
     $this->dispatch(new CreateTicket($ticket, $this->sendesk));
     return $this->respondSuccess();
 }
Example #7
0
 /**
  * Creates a ticket for the event for the logged-in user, or if the user
  * already has a ticket, return theirs.
  *
  * @param  Integer 	$eventId 	ID of the event for the ticket.
  * @return View 		        Ticket View
  */
 public function store()
 {
     $data = Request::only(["event_id", "stripeToken"]);
     try {
         $event = Event::findOrFail($data["event_id"]);
     } catch (ModelNotFoundException $e) {
         return Redirect::back()->withErrors(['message' => $this->errorMessages['event_not_found']]);
     }
     $user = Auth::user();
     if (Ticket::where('event_id', $event->id)->where('user_id', $user->id)->get()->toArray()) {
         return Redirect::back()->withErrors(["message" => $this->errorMessages['ticket_exists']]);
     }
     if ($event->price > 0) {
         // If the ticket ain't free you're going to have to pay for it.
         // Let's Stripe.
         Stripe::setApiKey(env('STRIPE_SECRET'));
         try {
             // Create a reference for a Customer relating to the Stripe token we received
             $customer = Customer::create(["email" => $user->email, "card" => $data["stripeToken"]]);
             // Now, charge that customer for the ticket as expected.
             $charge = Charge::create(["customer" => $customer->id, "amount" => $event->price * 100, "currency" => "eur"]);
         } catch (Error\Card $e) {
             return Redirect::back()->withErrors(["message" => $this->errorMessages['card_declined']]);
         } catch (Error\RateLimit $e) {
             return \Redirect::back()->withErrors(["message" => $this->errorMessages['server_error']]);
         } catch (Error\InvalidRequest $e) {
             dd($e);
             return Redirect::back()->withErrors(["message" => $this->errorMessages['dev_mistake']]);
         } catch (Error\Authentication $e) {
             return Redirect::back()->withErrors(["message" => $this->errorMessages['dev_mistake_auth']]);
         } catch (Error\ApiConnection $e) {
             return Redirect::back()->withErrors(["message" => $this->errorMessages['network_error']]);
         } catch (Error\Base $e) {
             // I actually don't know what this error means
             // or what it does, so probably panic
             return Redirect::back()->withErrors(["message" => $this->errorMessages['something_wrong']]);
         }
         $ticket = Ticket::create(["user_id" => $user->id, "event_id" => $event->id, "price" => $event->price, "used" => false, "printed" => false, "charge_id" => $charge->id]);
     } else {
         $ticket = Ticket::create(["user_id" => $user->id, "event_id" => $event->id, "price" => $event->price, "used" => false, "printed" => false, "charge_id" => null]);
     }
     MailController::sendTicket($ticket);
     return Redirect::back()->with('message', "You've got a ticket! Find your details and print it out here.");
 }
 /**
  * Actual process of storing Ticket
  *
  * @param TicketRequest $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function store(TicketRequest $request)
 {
     $input = $request->all();
     Ticket::create($input);
     return redirect('/tickets')->with(['flash_message' => 'You have successfully updated the ticket', 'flash_message_important' => true]);
 }
 /**
  * Actual process of storing Ticket
  *
  * @param TicketRequest $request
  * @return Redirector
  */
 public function store(TicketRequest $request)
 {
     $input = $request->all();
     $this->ticket->create($input);
     return redirect('/user/profile')->with(['flash_message' => 'You have successfully created a ticket', 'flash_message_important' => true]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Ticket::create(['title' => 'Ticket 1', 'user_id' => 1, 'project_id' => 1, 'priority' => 0.5, 'progress' => 0.4, 'est_time' => 1.2, 'status_id' => 1, 'severity_id' => 1, 'ticket_type_id' => 1, 'description' => str_random(50), 'assignee_id' => 1]);
     Ticket::create(['title' => 'Ticket 2', 'user_id' => 2, 'project_id' => 1, 'priority' => 0.4, 'progress' => 0.4, 'est_time' => 1.2, 'status_id' => 1, 'severity_id' => 1, 'ticket_type_id' => 1, 'description' => str_random(50), 'assignee_id' => 1]);
     Ticket::create(['title' => 'Ticket 3', 'user_id' => 2, 'project_id' => 1, 'priority' => 0.3, 'progress' => 0.4, 'est_time' => 1.2, 'status_id' => 1, 'severity_id' => 1, 'ticket_type_id' => 1, 'description' => str_random(50), 'assignee_id' => 1]);
 }
 public function store()
 {
     $input = Request::all();
     Ticket::create($input);
     return redirect('tickets');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['subject' => 'required|max:255', 'product' => 'required', 'group' => 'required', 'severity' => 'required', 'description' => 'required']);
     $settings = Settings::where('name', 'ticket_track_id')->first();
     $track_id = $settings->str_value;
     $customer = Customer::where('id', $this->my_customer_id)->first();
     $search_strings = ['%COMPANY_NAME', '%Y', '%m', '%d'];
     $value_strings = [str_replace(' ', '_', $customer->name), date('Y', time()), date('m', time()), date('d', time())];
     $track_id = str_replace($search_strings, $value_strings, $track_id);
     $ticket = Ticket::create(['subject' => $request->subject, 'track_id' => $track_id, 'description' => $request->description, 'group_id' => $request->group, 'severity_id' => $request->severity, 'product_id' => $request->product, 'user_id' => $this->my_id, 'customer_id' => $this->my_customer_id, 'status_id' => 1]);
     if (isset($request->attachments)) {
         foreach ($request->attachments as $attachment) {
             // Check that the directory exists
             $uploadPath = storage_path() . '/attachments/' . $ticket->id;
             $fs = new Filesystem();
             if (!$fs->isDirectory($uploadPath)) {
                 // Create the directory
                 $fs->makeDirectory($uploadPath);
             }
             $attachment->move($uploadPath, $attachment->getClientOriginalName());
             $_attachment = Attachment::create(['user_id' => $this->my_id, 'name' => $attachment->getClientOriginalName(), 'ticket_id' => $ticket->id]);
         }
     }
     $this->dispatch(new EmailNewTicket($ticket));
     return redirect('/tickets');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(TicketForm $request)
 {
     Ticket::create(['titulo' => $request->titulo, 'descripcion' => $request->descripcion, 'categoria_id' => $request->categoria_id, 'estado_id' => 1, 'user_id' => $request->user()->id]);
     return redirect('/tickets');
 }
 public function store(TicketFormRequest $request)
 {
     $request = $request->all();
     $request['user_id'] = \Auth::id();
     $request['slug'] = $slug = uniqid();
     //THIS COULD ALSO BE PUSHED TO THE FORM
     Ticket::create($request);
     //Sending an email when there is a new ticket
     $data = array('ticket' => $slug);
     Mail::send('emails.ticket', $data, function ($message) {
         $message->from('*****@*****.**', 'Ticket Support System');
         $message->to('*****@*****.**')->subject('A new concern added in the system!');
     });
     return redirect('/tickets')->with('status', 'Your ticket has been created! Its unique id is: ' . $slug);
 }