Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param Requests\CommentFormRequest|Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $comment = new Models\Comment();
     $comment->content = $request->get('content');
     $comment->ticket_id = $request->get('ticket_id');
     $comment->user_id = \Auth::user()->id;
     $comment->save();
     $ticket = Models\Ticket::find($comment->ticket_id);
     $ticket->updated_at = $comment->created_at;
     $ticket->save();
     return back()->with('status', trans('ticketit::lang.comment-has-been-added-ok'));
 }
Exemplo n.º 2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param Requests\CommentFormRequest|Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $comment = new Models\Comment();
     $comment->content = $request->get('content');
     $comment->ticket_id = $request->get('ticket_id');
     $comment->user_id = \Auth::user()->id;
     $comment->save();
     $ticket = Models\Ticket::find($comment->ticket_id);
     $ticket->updated_at = $comment->created_at;
     $ticket->save();
     return back()->with('status', 'Comment has been added successfully');
 }
Exemplo n.º 3
0
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     // Adding HTML5 color picker to form elements
     Form::macro('custom', function ($type, $name, $value = "#000000", $options = []) {
         $field = $this->input($type, $name, $value, $options);
         return $field;
     });
     // Passing to views the master view value from the setting file
     view()->composer('ticketit::*', function ($view) {
         $master = config('ticketit.master_template');
         $view->with(compact('master'));
     });
     // Send notification when new comment is added
     Comment::creating(function ($comment) {
         if (config('ticketit.comment_notification') == 'yes') {
             $notification = new NotificationsController();
             $notification->newComment($comment);
         }
     });
     // Send notification when ticket status is modified
     Ticket::updating(function ($modified_ticket) {
         if (config('ticketit.status_notification') == 'yes') {
             $original_ticket = Ticket::find($modified_ticket->id);
             if ($original_ticket->status->id != $modified_ticket->status->id) {
                 $notification = new NotificationsController();
                 $notification->ticketStatusUpdated($modified_ticket, $original_ticket);
             }
         }
         if (config('ticketit.assigned_notification') == 'yes') {
             $original_ticket = Ticket::find($modified_ticket->id);
             if ($original_ticket->agent->id != $modified_ticket->agent->id) {
                 $notification = new NotificationsController();
                 $notification->ticketAgentUpdated($modified_ticket, $original_ticket);
             }
         }
         return true;
     });
     // Send notification when ticket status is modified
     Ticket::created(function ($ticket) {
         if (config('ticketit.assigned_notification') == 'yes') {
             $notification = new NotificationsController();
             $notification->newTicketNotifyAgent($ticket);
         }
         return true;
     });
     $this->loadViewsFrom(__DIR__ . '/views', 'ticketit');
     $this->publishes([__DIR__ . '/views' => base_path('resources/views/vendor/ticketit')], 'views');
     $this->publishes([__DIR__ . '/config/ticketit.php' => config_path('ticketit.php')], 'config');
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     $installer = new InstallController();
     // if a migration is missing scape to the installation
     if (empty($installer->inactiveMigrations()) && DB::table('ticketit_settings')->count() != 0) {
         // Send the Agent User model to the view under $u
         view()->composer('*', function ($view) {
             if (auth()->check()) {
                 $u = Agent::find(auth()->user()->id);
                 $view->with('u', $u);
             }
             $setting = new Setting();
             $view->with('setting', $setting);
         });
         // Adding HTML5 color picker to form elements
         CollectiveForm::macro('custom', function ($type, $name, $value = "#000000", $options = []) {
             $field = $this->input($type, $name, $value, $options);
             return $field;
         });
         // Passing to views the master view value from the setting file
         view()->composer('ticketit::*', function ($view) {
             $tools = new ToolsController();
             $master = Setting::grab('master_template');
             $email = Setting::grab('email.template');
             $view->with(compact('master', 'email', 'tools'));
         });
         // Send notification when new comment is added
         Comment::creating(function ($comment) {
             if (Setting::grab('comment_notification')) {
                 $notification = new NotificationsController();
                 $notification->newComment($comment);
             }
         });
         // Send notification when ticket status is modified
         Ticket::updating(function ($modified_ticket) {
             if (Setting::grab('status_notification')) {
                 $original_ticket = Ticket::find($modified_ticket->id);
                 if ($original_ticket->status_id != $modified_ticket->status_id || $original_ticket->completed_at != $modified_ticket->completed_at) {
                     $notification = new NotificationsController();
                     $notification->ticketStatusUpdated($modified_ticket, $original_ticket);
                 }
             }
             if (Setting::grab('assigned_notification')) {
                 $original_ticket = Ticket::find($modified_ticket->id);
                 if ($original_ticket->agent->id != $modified_ticket->agent->id) {
                     $notification = new NotificationsController();
                     $notification->ticketAgentUpdated($modified_ticket, $original_ticket);
                 }
             }
             return true;
         });
         // Send notification when ticket status is modified
         Ticket::created(function ($ticket) {
             if (Setting::grab('assigned_notification')) {
                 $notification = new NotificationsController();
                 $notification->newTicketNotifyAgent($ticket);
             }
             return true;
         });
         $this->loadTranslationsFrom(__DIR__ . '/Translations', 'ticketit');
         $this->loadViewsFrom(__DIR__ . '/Views', 'ticketit');
         $this->publishes([__DIR__ . '/Views' => base_path('resources/views/vendor/ticketit')], 'views');
         $this->publishes([__DIR__ . '/Translations' => base_path('resources/lang/vendor/ticketit')], 'lang');
         $this->publishes([__DIR__ . '/Public' => public_path('vendor/ticketit')], 'public');
         $this->publishes([__DIR__ . '/Migrations' => base_path('database/migrations')], 'db');
         // Check public assets are present, publish them if not
         //            $installer->publicAssets();
         $main_route = Setting::grab('main_route');
         $admin_route = Setting::grab('admin_route');
         include __DIR__ . '/routes.php';
     } elseif (Request::path() == 'tickets-install') {
         $this->loadTranslationsFrom(__DIR__ . '/Translations', 'ticketit');
         $this->loadViewsFrom(__DIR__ . '/Views', 'ticketit');
         $this->publishes([__DIR__ . '/Migrations' => base_path('database/migrations')], 'db');
         Route::get('/tickets-install', ['middleware' => 'auth', 'uses' => 'Kordy\\Ticketit\\Controllers\\InstallController@index']);
         Route::post('/tickets-install', ['middleware' => 'auth', 'uses' => 'Kordy\\Ticketit\\Controllers\\InstallController@setup']);
     }
 }