Skip to content

Commit

Permalink
- updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
toni-suarez committed Jun 21, 2024
1 parent 238f3e3 commit bf8c6ab
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ php artisan vendor:publish --tag="utm-parameter"

### Middleware Configuration

Once the package is installed, you need to add the UtmParameters middleware to your Laravel application. Open the `bootstrap/app.php` file and append the `UtmParameters::class` inside the web-group.
Once the package is installed, you can add the UtmParameters middleware to your Laravel application. Open the `bootstrap/app.php` file and append the `UtmParameters::class` inside the web-group.

```php
# Laravel 11
Expand All @@ -51,6 +51,29 @@ return Application::configure(basePath: dirname(__DIR__))

Also, take a look at how to set an [alias for the middleware](https://github.com/toni-suarez/laravel-utm-parameter/wiki/Installation-Guide#step-3-alias-configuration-optional).

### Use as Facade

If you prefer not to use it as middleware, you can utilize the UtmParameter Facade directly in your controllers or other parts of your application. Once the `boot($request)`-method is called, you have access to it at any place. For example:

```php
use Suarez\UtmParameter\Facades\UtmParameter;

// Inside a controller method
class IndexController {
public function index(Request $request)
{
UtmParameter::boot($request);
}
}

class SomeDifferentController {
public function index(Request $request)
{
$source = UtmParameter::get('source');
}
}
```

## Configuration

The configuration file `config/utm-parameter.php` allows you to control the behavior of the UTM parameters handling.
Expand Down

0 comments on commit bf8c6ab

Please sign in to comment.