/** * Register custom form macros on package start * @return void */ public function boot() { Form::macro('uploadcare', function ($name, $value = null, $options = array()) { $options = array_merge($options, array('role' => 'uploadcare-uploader', 'value' => $value)); return Form::input('hidden', $name, $value, $options); }); }
/** * Bootstrap the application services. * * @return void */ public function boot() { Form::macro('custom', function ($type, $name, $value = "#000000", $options = []) { $field = $this->input($type, $name, $value, $options); return $field; }); view()->composer('Ticketit::*', function ($view) { $master = config('ticketit.master_template'); $view->with(compact('master')); }); $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() { // 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']); } }
Form::macro('radioSwitch', function ($name, $values = null, $checked = null, $options = array()) { if (is_null($values)) { $values = [1 => transpine('helpers.yes'), 0 => transpine('helpers.no')]; $checked = is_null($checked) ? null : (int) $checked; } if (is_null($checked)) { $checked = array_keys($values)[0]; } $html = '<p class="field switch">'; foreach ($values as $value => $label) { $options['id'] = $name . $value . microtime(); $html .= Form::radio($name, $value, $checked === $value, $options); $labelClass = $value == 0 ? 'cb-disable' : 'cb-enable'; $labelClass .= $checked === $value ? ' selected' : ''; $html .= Form::label($options['id'], $label, ['class' => $labelClass]); } $html .= '</p>'; return $html; }); /** * Create a checkbox input field with forced zero value for unchecked. * * @param string $name * @param mixed $value * @param bool $checked * @param array $options * @return string */ Form::macro('checkboxForced', function ($name, $value = 1, $checked = null, $options = array()) { return Form::hidden($name, 0) . Form::checkbox($name, $value, $checked, $options); });
FormFacade::macro('spinner', function ($name, $defaultValue, $params) { $paramsString = ''; $defaultMin = ''; $defaultMax = ''; $defaultStep = ''; foreach ($params as $key => $value) { if ($key == 'value') { $defaultValue = $value; } else { if ($key == 'min') { $defaultMin = $value; } else { if ($key == 'max') { $defaultMax = $value; } else { if ($key == 'step') { $defaultStep = $value; } } } } $paramsString = $paramsString . " " . $key . ' = "' . $value . '"'; } if ($defaultValue != null) { $paramsString = $paramsString . ' value="' . $defaultValue . '"'; } if ($defaultMin == '') { $defaultMin = 0; $paramsString = $paramsString . ' min="' . $defaultMin . '"'; } if ($defaultMax == '') { $defaultMax = 100; $paramsString = $paramsString . ' max="' . $defaultMax . '"'; } if ($defaultStep == '') { $defaultStep = 1; $paramsString = $paramsString . ' step="' . $defaultStep . '"'; } return '<div class="input-group spinner" style="width:100%; margin-bottom:15px;"> <input name="' . $name . '" type="text" pattern="[0-9]*" data-oldvalue="' . $defaultValue . '" onchange="var max = parseInt($(this).attr(\'max\')); var min = parseInt($(this).attr(\'min\')); var oldValue = $(this).attr(\'data-oldvalue\'); var value = $(this).val(); if(/^\\d+$/.test(value)==false||value>max||value<min){$(this).val(oldValue)}else{$(this).attr(\'data-oldvalue\',value);$(this).val(parseInt(value))}" ' . $paramsString . '> <div class="input-group-btn-vertical" style="width:30px; position: relative;white-space: nowrap;vertical-align: middle;display: table-cell;"> <button style ="border-left:none;font-size:62.5%;border-radius: 0; border-bottom:none;border-top-right-radius: 4px;display: block;float: none;height: 50%;width: 100%;max-width: 100%;margin-left: -1%;position: absolute;top:0;" class="btn btn-xs btn-default" type="button" onclick="var $input = $(this).parent().parent().children(\':first-child\'); var oldValue = parseInt($input.attr(\'data-oldvalue\')); var value = parseInt($input.val()); var pas = parseInt($input.attr(\'step\')); var max = parseInt($input.attr(\'max\')); if(value + pas <=100){$input.val(value + pas); $input.attr(\'data-oldvalue\',value + pas);}"><i class="glyphicon glyphicon-triangle-top" style="vertical-align:middle;display:block;position:initial;line-height:100%"></i></button> <button style ="border-left:none;font-size:62.5%;border-radius: 0; border-bottom-right-radius: 4px;display: block;float: none;height: 50%;width: 100%;max-width: 100%;margin-left: -1%;position: absolute;bottom:0;" class="btn btn-xs btn-default" type="button" onclick="var $input = $(this).parent().parent().children(\':first-child\'); var oldValue = parseInt($input.attr(\'data-oldvalue\')); var value = parseInt($input.val()); var pas = parseInt($input.attr(\'step\')); var min = parseInt($input.attr(\'min\')); if(value - pas >=0) {$input.val(value - pas); $input.attr(\'data-oldvalue\',value - pas);}"><i class="glyphicon glyphicon-triangle-bottom" style="vertical-align:middle;display:block; position:initial;line-height:100%"></i></button> </div> </div>'; });