Exemplo n.º 1
0
 public function destroy($key)
 {
     if (!Helper::getMode()) {
         return redirect()->back()->withErrors(config('constants.DISABLE_MESSAGE'));
     }
     if (!Entrust::can('manage_template')) {
         return redirect('/dashboard')->withErrors(config('constants.NA'));
     }
     $templates = Helper::getTemplate();
     if (!array_key_exists($key, $templates)) {
         return redirect()->back()->withErrors(config('constants.NA'));
     }
     if ($templates[$key]['category'] == 'system') {
         return redirect()->back()->withErrors('This template cannot be deleted.');
     }
     unset($templates[$key]);
     $filename = base_path() . '/config/template/' . DOMAIN . '/' . $key;
     if (File::exists($filename)) {
         File::delete($filename);
     }
     $filename = base_path() . '/config/template.php';
     File::put($filename, var_export($templates, true));
     File::prepend($filename, '<?php return ');
     File::append($filename, ';');
     return redirect()->back()->withSuccess(config('constants.DELETED'));
 }
Exemplo n.º 2
0
 public function show(Ticket $ticket)
 {
     if (!Entrust::can('view_ticket')) {
         return redirect('/dashboard')->withErrors(config('constants.NA'));
     }
     if (!Entrust::hasRole('admin')) {
         $ticket = $ticket->with('assignedUser')->whereId($ticket->id)->whereHas('assignedUser', function ($query) {
             $query->where('user_id', '=', Auth::user()->id);
         })->first();
     }
     if (!$ticket) {
         return redirect('/ticket')->withErrors('You cannot access a ticket without permission.');
     }
     $departments = Department::lists('department_name', 'id')->all();
     $ticket_types = TicketType::lists('ticket_type_name', 'id')->all();
     $priorities = config('list.priority');
     $ticket_status = config('list.ticket_status');
     $comments = \App\Comment::whereBelongsTo('ticket')->whereUniqueId($ticket->id)->get();
     $note = \App\Note::whereBelongsTo('ticket')->whereUniqueId($ticket->id)->first();
     $attachments = \App\Attachment::whereBelongsTo('ticket')->whereUniqueId($ticket->id)->get();
     $ticket_array = $ticket->toArray();
     $users = User::with('roles')->whereHas('roles', function ($query) {
         $query->where('roles.name', '!=', 'user');
     })->lists('name', 'id')->all();
     $ticket_with_user = $ticket->whereId($ticket->id)->with('assignedUser')->first();
     $selected_users = array();
     foreach ($ticket_with_user->assignedUser as $user) {
         $selected_users[] = $user->id;
     }
     $custom_field_values = Helper::getCustomFieldValues($this->form, $ticket->id);
     $template_list = array();
     $templates = Helper::getTemplate();
     foreach ($templates as $key => $template) {
         if ($key != 'forgot_password' && $template['category'] == 'ticket') {
             $template_list[$key] = $template['title'];
         }
     }
     return view('ticket.show', compact('ticket', 'departments', 'ticket_types', 'priorities', 'users', 'selected_users', 'ticket_with_user', 'ticket_array', 'ticket_status', 'comments', 'note', 'attachments', 'custom_field_values', 'template_list'));
 }