Skip to content

Commit

Permalink
- Laravel 10
Browse files Browse the repository at this point in the history
  • Loading branch information
toni-suarez committed Mar 16, 2024
1 parent 57a3913 commit 10ccfc2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 55 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/tests-php8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ jobs:

strategy:
matrix:
laravel: ['10.*', '11.*']
laravel: ['10.*']
php: [8.1, 8.2]
exclude:
- laravel: '11.*'
php: 8.1
fail-fast: false

name: Laravel ${{ matrix.laravel }}, PHP ${{ matrix.php }}
Expand Down
49 changes: 2 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,55 +48,10 @@ $ composer require suarez/laravel-utm-parameter

### Middleware

#### Laravel 11

Open the `bootstrap/app.php` file and append the `UtmParameters::class` inside the web-group

```php
# Laravel 11
return Application::configure(basePath: dirname(__DIR__))
...
->withMiddleware(function (Middleware $middleware) {
$middleware->web(append: [
Suarez\UtmParameter\Middleware\UtmParameters::class,
/* ... keep the existing middleware here */
]);
})
...
```

To enable UTM-Parameters only for certain requests to your site, add a new alias.

```php
# Laravel 11
use Suarez\UtmParameter\Middleware\UtmParameters;

->withMiddleware(function (Middleware $middleware) {
$middleware
->alias([
/* ... keep the existing mappings here */
'utm-parameters' => UtmParameters::class,
])
->web(append: [
/* ... keep the existing mappings here */
UtmParameters::class
]);
})
```

To apply UTM-Parameters to specific routes, use the following middleware: `utm-parameters`

```php
Route::middleware('utm-parameters')
->get('langing-page/{slug}', 'LandingPageController@show');
```

#### Laravel 10

Open the `app/Http/Kernel.php` file and add a new item to the `web` middleware group:

```php
# Laravel 10 and below
# Laravel 10
protected $middlewareGroups = [
'web' => [
/* ... keep the existing middleware here */
Expand All @@ -108,7 +63,7 @@ protected $middlewareGroups = [
To enable UTM-Parameters only for certain requests to your site, add a new mapping to the `middlewareAliases` Array.

```php
# Laravel 10 and below
# Laravel 10
protected $middlewareAliases = [
/* ... keep the existing mappings here */
'utm-parameters' => \Suarez\UtmParameter\Middleware\UtmParameters::class,
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
],
"require": {
"php": "^8.1|^8.2",
"illuminate/support": "^10.0|^11.0",
"illuminate/contracts": "^10.0|^11.0"
"illuminate/support": "^10.0",
"illuminate/contracts": "^10.0"
},
"require-dev": {
"nunomaduro/collision": "^7.0|^8.1",
"orchestra/testbench": "^7.0|^8.0|^9.0",
"nunomaduro/collision": "^7.0",
"orchestra/testbench": "^8.0",
"phpunit/phpunit": "^9.5|^10.0",
"friendsofphp/php-cs-fixer": "^3.0"
},
Expand Down

0 comments on commit 10ccfc2

Please sign in to comment.