# 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`

## Overriding submit button:

You can override the submit button without the need to override the whole `edit-add.blade.php` by extending the `submit-buttons` section:

```
@extends('voyager::bread.edit-add')
@section('submit-buttons')
    @parent
    <button type="submit" class="btn btn-primary save">Save And Publish</button>
@endsection
```

## Using custom Controllers

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

```php
<?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:

![](https://1486345001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LOZ_fG1zbRQxFD0p8uB-4025916689%2Fuploads%2Fgit-blob-5f1413711c5cf86df89feaa82e730640c14d8a2b%2Fbread_controller.png?alt=media\&token=560f3fd4-1ade-4f7c-8bce-354577abd67a)

You can now override all methods from the [VoyagerBaseController](https://github.com/the-control-group/voyager/blob/1.5/src/Http/Controllers/VoyagerBaseController.php)

## Overriding Voyagers Controllers

{% hint style="danger" %}
**Only use this method if you know what you are doing**\
We don't recommend or support overriding all controllers as you won't get any code-changes made in future updates.
{% endhint %}

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

```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:

```php
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
<?php

namespace App\Providers;

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

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        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
<?php

namespace App;

class DataRow extends \TCG\Voyager\Models\DataRow
{
    // ...
}
```

If the model you are overriding has an associated BREAD, go to the BREAD settings for the model you are overriding and replace the Model Name with your fully-qualified class-name. For example, if you are overriding the Voyager `Menu` model with your own `App\Menu` model:

![](https://1486345001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LOZ_fG1zbRQxFD0p8uB-4025916689%2Fuploads%2Fgit-blob-ab9a288736c9ee18553a936da956a3e9867c7a38%2Fbread_override_voyager_models.png?alt=media\&token=552e7280-32da-46e6-aaa3-a69cbd8c0bbe)
