Voyager
HomeGithubIssues
1.1
1.1
  • Introduction
  • Getting started
    • What is Voyager
    • Installation
    • Upgrading
    • Configurations
  • Core concepts
    • Routing
    • Media Manager
    • Menus and Menu Builder
    • Database Manager
    • BREAD Builder
    • Settings
    • Compass
    • Roles and Permissions
    • Helper methods
    • Multilanguage
  • Customization
    • Overriding files
    • Overriding Routes
    • Additional CSS and JS
    • Enabling Soft-Delete
    • Custom relationship attributes
    • TinyMCE
    • Adding custom Formfields
    • Coordinates
  • Troubleshooting
    • Using HTTPS on yours site
    • Missing required parameter
Powered by GitBook
On this page
  • Overriding BREAD Views
  • Using custom Controllers
  • Overriding Voyagers Controllers
  • Overriding Voyager-Models
Export as PDF
  1. Customization

Overriding files

Overriding BREAD Views

You can override any of the BREAD views for a single BREAD by creating a new folder in resources/views/vendor/voyager/slug-name where slug-name is the slug that you have assigned for that table. There are 4 files that you can override:

  • browse.blade.php

  • edit-add.blade.php

  • read.blade.php

  • order.blade.php

Alternatively you can override the views for all BREADs by creating any of the above files under resources/views/vendor/voyager/bread

Using custom Controllers

You can override the controller for a single BREAD by creating a controller which extends Voyagers controller, for example:

<?php

namespace App\Http\Controllers;

class VoyagerCategoriesController extends \TCG\Voyager\Http\Controllers\VoyagerBaseController
{
    //...
}

After that go to the BREAD-settings and fill in the Controller Name with your fully-qualified class-name:

Overriding Voyagers Controllers

If you want to override any of Voyagers core controllers you first have to change your config file config/voyager.php:

/*
|--------------------------------------------------------------------------
| Controllers config
|--------------------------------------------------------------------------
|
| Here you can specify voyager controller settings
|
*/
​
'controllers' => [
    'namespace' => 'App\\Http\\Controllers\\Voyager',
],

Then run php artisan voyager:controllers, Voyager will now use the child controllers which will be created at App/Http/Controllers/Voyager

Overriding Voyager-Models

You are also able to override Voyagers models if you need to. To do so, you need to add the following to your AppServiceProviders register method:

Voyager::useModel($name, $object);

Where name is the class-name of the model and object the fully-qualified name of your custom model. For example:

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Events\Dispatcher;
use TCG\Voyager\Facades\Voyager;

class AppServiceProvider extends ServiceProvider
{
    public function register()
    {
        Voyager::useModel('DataRow', \App\DataRow::class);
    }
    // ...
}

The next step is to create your model and make it extend the original model. In case of DataRow:

<?php

namespace App;

class DataRow extends \TCG\Voyager\Models\DataRow
{
    // ...
}
PreviousMultilanguageNextOverriding Routes

Last updated 5 years ago

You can now override all methods from the

VoyagerBaseController