tracker icon indicating copy to clipboard operation
tracker copied to clipboard

Is there a way to publish the views and controllers?

Open smurfiez opened this issue 6 years ago • 1 comments

SB admin is nice but I'm using AdminLTE , is there a command to publish the views and controllers that I can modify?

smurfiez avatar Jun 25 '19 17:06 smurfiez

I did the following to allow myself to modify the views:

Copy all of the vendor/pragmarx/tracker/src/views/* files into your application resources directory.

$ cp vendor/pragmarx/tracker/src/views/* /var/www/html/my_app/resources/views/tracking/

Then, extend the PragmaRX\Tracker\Vendor\Laravel\ServiceProvider.php by creating a new class in your app directory. I put mine in app/Extensions/TrackerServiceProvider.php

namespace App\Extensions;

use PragmaRX\Tracker\Vendor\Laravel\ServiceProvider as PragmaRXServiceProvider;

class TrackerServiceProvider extends PragmaRXServiceProvider
{

    /**
     * Register global view composers.
     */
    protected function registerGlobalViewComposers()
    {
        $me = $this;

        $this->app->make('view')->composer('pragmarx/tracker::*', function ($view) use ($me) {

            // Force the system to use my own provided views.
            $parts = explode('::', $view->getName());
            $viewName = array_pop($parts);
            $view->setPath(resource_path('views').'/tracker/'.$viewName.'.blade.php');


            // Continue with the rest of the code.
            $view->with('stats_layout', $me->getConfig('stats_layout'));

            $template_path = url('/').$me->getConfig('stats_template_path');

            $view->with('stats_template_path', $template_path);
        });
    }
}

Then update the config/app.php file to use your new class rather than the Pramarx class inside the 'providers' array:

// PragmaRX\Tracker\Vendor\Laravel\ServiceProvider::class,
App\Extensions\TrackerServiceProvider::class,

I also updated the config/tracker/php file to use the following:

'stats_layout' => 'tracker.layout', // tracker is the path under my views directory where I store the pragmarx view files.

dbetts avatar May 13 '20 16:05 dbetts