# Customizations

You may want to do your own customizations and modifications on the code such as the `views` or the `controllers` to add a new feature for example ... etc. so, all you need is to publish the required `asset` mentioned below and start your own customizations!

## Package's assets

* `config`
* `views`
* `assets` (js, css, imgs)
* `models`
* `migrations`
* `controllers`
* `routes`

{% hint style="info" %}
The following assets already been published during the installation process:

`config`, `views`, `assets`, `models`, `migrations`

only the `controllers` asset is not published until you do.
{% endhint %}

### Publishing the assets

When you need to publish an asset, all you need is to run the following command :

```
php artisan vendor:publish --tag=chatify-<asset-name>
```

{% hint style="info" %}
Change`<asset-name>` with the required asset name (e.g. config) to be like `chatify-config`
{% endhint %}

### Controllers

You may want to do some modifications on the controllers of this package, so you need to follow the steps below:

1. Publish `controllers` asset

```
php artisan vendor:publish --tag=chatify-controllers
```

2\. Go to `config/chatify.php` and from `routes` properties, change `namespace` to `App\Http\Controllers\vendor\Chatify` to be like the following:

{% code title="config/chatify.php" %}

```php
...
'namespace' => env('CHATIFY_ROUTES_NAMESPACE', 'App\Http\Controllers\vendor\Chatify'),
```

{% endcode %}

same for `api_routes`, change the `namespace` to `App\Http\Controllers\vendor\Chatify\Api`&#x20;

{% code title="config/chatify.php" %}

```php
... 
'namespace' => env('CHATIFY_API_ROUTES_NAMESPACE', 'App\Http\Controllers\vendor\Chatify\Api').
```

{% endcode %}

3\. Go to `app/Http/Controllers/vendor/Chatify` and open `MessagesController.php` with your code editor .. then change the namespace to the same namespace specified in the step 2 above ..&#x20;

the same for `Api\MessagesController.php` .

Thats all you need to do.

Now, You can work with package's controller and start your modifications.

## Custom Chatify Class

When you want to override a method in `ChatifyMessenger.php` which is the main class of Chatify, then you have to follow the steps below:

* Create a class in your Laravel application (e.g. `CustomChatify.php`).
* inside your class, extend `Chatify/ChatifyMessenger`

```php
// CustomChatify.php

<?php

//...
use Chatify\ChatifyMessenger

class CustomChatify extends ChatifyMessenger{

    // Here, override the methods you want. 
    // For example:
    public function fetchMessage($id, $index = null)
    {
        //...
    }
}
```

* Use your custom class `CustomChatify` at `MessegesController.php` for both web and api controllers  if needed, instead of `Chatify`:

```php
// MessagesController.php
<?php
namespace App\Http\Controllers\vendor\Chatify;

//...
use Chatify\Facades\ChatifyMessenger as Chatify; // instead of this (remove it)
use Path\To\CustomChatify as Chatify; // use this (yours), use the right path/namespace to your custom class.
//...

class MessagesController extends Controller
{
//...
}
```

## Custom Routes

You may want to do some modifications on the `routes` of this package, so you need to follow the steps below:

1. Publish `routes` asset

```
php artisan vendor:publish --tag=chatify-routes
```

2. go to the config file of the package in your app \`config/chatify.php\` the modify the following:

<pre class="language-php"><code class="lang-php">// config/chatify.php

<strong>...
</strong><strong>/*
</strong>|-------------------------------------
| Routes configurations
|-------------------------------------
*/
'routes' => [
    'custom' => env('CHATIFY_CUSTOM_ROUTES', false), // set to true
    ...
],
...

</code></pre>

## Other Customizations

other customization such as

* Messenger name.
* Messenger colors.
* Messenger Max upload size.
* Messenger avatar.

&#x20;can be done by the [configurations](https://chatify.munafio.com/configurations) section.
