public function store(CreateTicketRequestRequest $request) { $draft = TicketsController::API()->getDraft(); $ticket = $draft ? $draft : new Ticket(); $post = ""; foreach ($this->questions as $key => $question) { $post .= "**" . $question . "** \n"; $post .= $request->get($key) == "" ? "[not answered]" : $request->get($key); $post .= "\n\n"; } $ticket->title = $request->get("title"); $ticket->creator_id = Auth::user()->active_contact->id; $ticket->company_id = Auth::user()->active_contact->company->id; $ticket->contact_id = Auth::user()->active_contact->id; $ticket->post = $post; $ticket->status_id = TICKET_REQUESTING_STATUS_ID; $ticket->assignee_id = 0; $ticket->priority_id = 0; $ticket->division_id = 0; $ticket->equipment_id = 0; $ticket->job_type_id = 0; $ticket->level_id = 0; $ticket->save(); $this->updateHistory($ticket); EmailsManager::sendTicketRequest($ticket->id); SlackManager::sendTicketRequest($ticket); return redirect()->route('tickets.index')->with('successes', ['Ticket request created successfully']); }
/** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { $schedule->call(function () { $tickets = TicketsController::API()->all(['where' => ['deadline|<|0', 'deadline|>|-60'], 'paginate' => 'false']); foreach ($tickets as $ticket) { EmailsManager::sendEscalation($ticket->id); SlackManager::sendEscalation($ticket); } })->everyMinute(); $schedule->call(function () { SlackManager::setChannelsTopic(); })->twiceDaily(7, 15); }
public function store(CreatePostRequest $request) { $draft = $draft = Post::where('author_id', Auth::user()->active_contact->id)->where("status_id", "=", POST_DRAFT_STATUS_ID)->where("ticket_id", $request->get("ticket_id"))->first(); $post = $draft ? $draft : new Post(); $post->ticket_id = $request->get('ticket_id'); $post->post = $request->get('post'); $post->author_id = Auth::user()->active_contact->id; $post->status_id = $request->get('is_public') ? POST_PUBLIC_STATUS_ID : POST_PRIVATE_STATUS_ID; $post->ticket_status_id = $request->get('status_id'); if (isset($post->updated_at)) { $post->created_at = $post->updated_at; } $post->save(); $ticket_updated = $this->updateTicket($request); EmailsManager::sendPost($post->id, $ticket_updated, $request->get('emails')); SlackManager::sendPost($post, $ticket_updated); return redirect()->route('tickets.show', $request->input('ticket_id'))->with('successes', ['Post created successfully']); }
public function update($id, UpdateTicketRequest $request) { $ticket = self::API()->find(['id' => $id]); $ticket->company_id = $request->get('company_id'); $ticket->title = $request->get('title'); $ticket->post = $request->get('post'); $ticket->assignee_id = $request->get('assignee_id'); $ticket->division_id = $request->get('division_id'); $ticket->equipment_id = $request->get('equipment_id'); $ticket->contact_id = $request->get('contact_id'); $ticket->job_type_id = $request->get('job_type_id'); $ticket->level_id = $request->get('level_id'); $ticket->emails = $request->get('emails'); $ticket->priority_id = $request->get('priority_id'); if ($ticket->status_id == TICKET_REQUESTING_STATUS_ID) { $ticket->status_id = TICKET_NEW_STATUS_ID; } $this->updateLinks($ticket); $this->updateTags($ticket); if ($ticket->isDirty()) { $ticket->save(); $this->updateHistory($ticket); EmailsManager::sendTicketUpdate($ticket->id); SlackManager::sendTicketUpdate($ticket); } return redirect()->route('tickets.show', $id)->with('successes', ['Ticket updated successfully']); }