Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8.0 #258

Merged
merged 80 commits into from
Apr 26, 2024
Merged

8.0 #258

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
7d10f75
Added "whichbrowser/parser" as a Composer dependency.
ash-jc-allen Apr 25, 2024
7d60418
Use "WhichBrowser/Parser" to parse the user agent header.
ash-jc-allen Apr 25, 2024
de187c4
Updated method to allow nullable user agents.
ash-jc-allen Apr 25, 2024
b616c9d
Removed mentions of jenssegers/agent.
ash-jc-allen Apr 25, 2024
b64ee6d
Removed "jenssegers/agent" Composer dependency.
ash-jc-allen Apr 25, 2024
b9369a4
Apply fixes from StyleCI
StyleCIBot Apr 25, 2024
66aff45
Merge pull request #255 from ash-jc-allen/analysis-newQvN
ash-jc-allen Apr 25, 2024
3212b50
Bumped minimum PHP version to 8.1
ash-jc-allen Apr 25, 2024
2dfee17
Dropped support for Laravel 8 and 9.
ash-jc-allen Apr 25, 2024
54eb935
Updated workflows to only run supported versions.
ash-jc-allen Apr 25, 2024
dbab293
Merge pull request #257 from ash-jc-allen/min-versions
ash-jc-allen Apr 25, 2024
0c644d5
Merge branch 'refs/heads/8.0' into feature/user-agent-drivers
ash-jc-allen Apr 25, 2024
2f3ce2b
Merge pull request #256 from ash-jc-allen/feature/user-agent-drivers
ash-jc-allen Apr 25, 2024
6e4f502
Bump minimum PHP version to 8.1.
ash-jc-allen Apr 25, 2024
2f4af25
Refactor "if" statement to a "match" condition
ash-jc-allen Apr 25, 2024
45a05cd
Merge pull request #259 from ash-jc-allen/match-statement
ash-jc-allen Apr 25, 2024
ab74ad0
Made the user agent parsing class configurable.
ash-jc-allen Apr 25, 2024
a16f62a
Apply fixes from StyleCI
StyleCIBot Apr 25, 2024
aa57629
Merge pull request #260 from ash-jc-allen/analysis-16Ke0L
ash-jc-allen Apr 25, 2024
ae853aa
Merge pull request #261 from ash-jc-allen/feature/configurable-user-a…
ash-jc-allen Apr 25, 2024
a5aa4b7
Added a new interface for the key generator.
ash-jc-allen Apr 25, 2024
26870b8
Resolve the key generator from the service container.
ash-jc-allen Apr 25, 2024
2bf5976
Use dependency injection instead of the service locator pattern.
ash-jc-allen Apr 25, 2024
e14bc07
Apply fixes from StyleCI
StyleCIBot Apr 25, 2024
09f8f65
Merge pull request #263 from ash-jc-allen/analysis-LZVwWw
ash-jc-allen Apr 25, 2024
17fde1b
Merge pull request #262 from ash-jc-allen/feature/key-generator-inter…
ash-jc-allen Apr 25, 2024
ff6955c
Make arguments required.
ash-jc-allen Apr 25, 2024
6ca2e7c
Merge pull request #264 from ash-jc-allen/feature/dependency-injectio…
ash-jc-allen Apr 25, 2024
7be2808
Added strict type checking.
ash-jc-allen Apr 25, 2024
1fffef3
Removed unneeded docblock tags.
ash-jc-allen Apr 25, 2024
c6dea42
Added "public" for public consts.
ash-jc-allen Apr 25, 2024
4b7df3f
Removed unneeded docblock tags.
ash-jc-allen Apr 25, 2024
e0e25e0
Removed unneeded docblock tags.
ash-jc-allen Apr 25, 2024
1a3528f
Added property types and removed unneeded docblock tags.
ash-jc-allen Apr 25, 2024
45b9d74
Removed unneeded docblock tags.
ash-jc-allen Apr 25, 2024
ed95a03
Added property types.
ash-jc-allen Apr 25, 2024
063e6c0
Merge pull request #265 from ash-jc-allen/feature/strict-types
ash-jc-allen Apr 25, 2024
942b5d4
Moved the "casts" property above all methods.
ash-jc-allen Apr 25, 2024
82e8f00
Deleted the unused "dates" property removed in Laravel 10.
ash-jc-allen Apr 25, 2024
6cbf1cb
Merge pull request #266 from ash-jc-allen/feature/remove-dates
ash-jc-allen Apr 25, 2024
3f608fd
Cleaned up comments.
ash-jc-allen Apr 25, 2024
837fa14
Switched from "nunomaduro/larastan" to "larastan/larastan".
ash-jc-allen Apr 25, 2024
7eca531
Use correct path for Larastan config.
ash-jc-allen Apr 25, 2024
637aada
Merge pull request #267 from ash-jc-allen/larastan
ash-jc-allen Apr 25, 2024
92a9491
Bump PHPUnit dependencies
laravel-shift Apr 25, 2024
ed0a461
Ignore PHPUnit cache folder
laravel-shift Apr 25, 2024
cd01026
Adopt PHP attributes in test classes
laravel-shift Apr 25, 2024
a29e16f
Add return types to test methods
laravel-shift Apr 25, 2024
e750eaf
Define test classes as `final`
laravel-shift Apr 25, 2024
3b79294
Added support for PHPUnit 11.
ash-jc-allen Apr 25, 2024
88d8895
Update to the newer PHPUnit config file.
ash-jc-allen Apr 25, 2024
cd3316b
Fix issues with inline data providers.
ash-jc-allen Apr 25, 2024
a2cc658
Apply fixes from StyleCI
StyleCIBot Apr 25, 2024
31083e2
Merge pull request #271 from ash-jc-allen/analysis-4wJ63n
ash-jc-allen Apr 25, 2024
cccfdfe
Merge pull request #268 from ash-jc-allen/shift-117366
ash-jc-allen Apr 25, 2024
71e532f
Add "pestphp/pest-plugin-laravel" Composer dependency.
ash-jc-allen Apr 26, 2024
ced346f
Add Pest architecture tests.
ash-jc-allen Apr 26, 2024
6e1c9b3
Run tests using Pest.
ash-jc-allen Apr 26, 2024
b385566
Apply fixes from StyleCI
StyleCIBot Apr 26, 2024
23c591d
Merge pull request #273 from ash-jc-allen/analysis-a63mZV
ash-jc-allen Apr 26, 2024
c896cfa
Merge pull request #274 from ash-jc-allen/arch-testing
ash-jc-allen Apr 26, 2024
7cfddcf
Updated changelog.
ash-jc-allen Apr 26, 2024
b521932
Added upgrade guide.
ash-jc-allen Apr 26, 2024
a2116b1
Reordered changelog.
ash-jc-allen Apr 26, 2024
c3f19be
Updated readme with v8 changes.
ash-jc-allen Apr 26, 2024
0ac293e
Updated migration.
ash-jc-allen Apr 26, 2024
efb7fb9
Updated changelog.
ash-jc-allen Apr 26, 2024
ab5b180
Merge pull request #275 from ash-jc-allen/8.0-doc-updates
ash-jc-allen Apr 26, 2024
58e3f4f
Merge remote-tracking branch 'refs/remotes/origin/master' into 8.0
ash-jc-allen Apr 26, 2024
487ccd6
Added "ashallendesign/laravel-config-validator" Composer dependency.
ash-jc-allen Apr 26, 2024
dd3d516
Added strict-type declaration.
ash-jc-allen Apr 26, 2024
f474c0c
Bumped minimum version of "ashallendesign/laravel-config-validator" t…
ash-jc-allen Apr 26, 2024
205879c
Use Laravel Config Validator for validating the "short-url" config.
ash-jc-allen Apr 26, 2024
6e39d14
Use "if" instead of a try/catch block.
ash-jc-allen Apr 26, 2024
a5a10ec
Removed unneeded validation check.
ash-jc-allen Apr 26, 2024
2cf3617
Apply fixes from StyleCI
StyleCIBot Apr 26, 2024
168392c
Merge pull request #279 from ash-jc-allen/analysis-maPGbY
ash-jc-allen Apr 26, 2024
4e9a1df
Merge pull request #278 from ash-jc-allen/feature/config-validation
ash-jc-allen Apr 26, 2024
035d322
Updated changelog.
ash-jc-allen Apr 26, 2024
5aadd20
Show how to create the short URL builder using the service container.
ash-jc-allen Apr 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions .github/workflows/ci-phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,14 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [8.0, 8.1, 8.2, 8.3]
laravel: [9.*, 10.*, 11.*]
php: [8.1, 8.2, 8.3]
laravel: [10.*, 11.*]
include:
- laravel: 11.*
testbench: 9.*
- laravel: 10.*
testbench: 8.*
- laravel: 9.*
testbench: 7.*
exclude:
- laravel: 10.*
php: 8.0
- laravel: 11.*
php: 8.0
- laravel: 11.*
php: 8.1

Expand Down
14 changes: 3 additions & 11 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,14 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [8.0, 8.1, 8.2, 8.3]
laravel: [8.*, 9.*, 10.*, 11.*]
php: [8.1, 8.2, 8.3]
laravel: [10.*, 11.*]
include:
- laravel: 11.*
testbench: 9.*
- laravel: 10.*
testbench: 8.*
- laravel: 9.*
testbench: 7.*
- laravel: 8.*
testbench: 6.*
exclude:
- laravel: 10.*
php: 8.0
- laravel: 11.*
php: 8.0
- laravel: 11.*
php: 8.1

Expand Down Expand Up @@ -53,4 +45,4 @@ jobs:
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --prefer-dist --no-interaction --no-suggest
- name: Execute tests
run: vendor/bin/phpunit
run: vendor/bin/pest
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.idea/
vendor/
composer.lock
.phpunit.result.cache
/.phpunit.cache
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

**v8.0.0 (released 2024-04-XX):**

- Switch from `jenssegers/agent` to `whichbrowser/parser` for user agent parsing. [#261](https://github.com/ash-jc-allen/short-url/pull/261), [#256](https://github.com/ash-jc-allen/short-url/pull/256)
- Added property types and strict type-checking. [#265](https://github.com/ash-jc-allen/short-url/pull/265)
- Added support for PHPUnit 11. [#268](https://github.com/ash-jc-allen/short-url/pull/268)
- Added Pest architecture tests. [#274](https://github.com/ash-jc-allen/short-url/pull/274)
- Switch to `ashallendesign/laravel-config-validator` to validate the package's config. [#278](https://github.com/ash-jc-allen/short-url/pull/278)
- Dropped support for PHP 8.0. [#257](https://github.com/ash-jc-allen/short-url/pull/257)
- Dropped support for Laravel 8 and 9. [#257](https://github.com/ash-jc-allen/short-url/pull/257)
- Dropped support for PHPUnit 8 and 9. [#268](https://github.com/ash-jc-allen/short-url/pull/268)
- Switched from "nunomaduro/larastan" to "larastan/larastan". [#267](https://github.com/ash-jc-allen/short-url/pull/267)
- Removed the `date` property from the `ShortURL` and `ShortURLVisit` models. [#266](https://github.com/ash-jc-allen/short-url/pull/266)
- Abstract the key generator out to use an interface. [#262](https://github.com/ash-jc-allen/short-url/pull/262)
- Updated the facade to include all methods in the docblock. [#252](https://github.com/ash-jc-allen/short-url/pull/252)

Huge thank you to [@stevebauman](https://github.com/stevebauman) and [@marzvrover](https://github.com/marzvrover) for their contributions in this release. I really appreciate it! 🚀

**v7.10.0 (released 2024-03-19):**

- Added support for nesbot/carbon 3.0. [#246](https://github.com/ash-jc-allen/short-url/pull/246)
Expand Down
132 changes: 82 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
- [Tracking Fields](#tracking-fields)
- [Config Validation](#config-validation)
- [Custom Database Connection](#custom-database-connection)
- [Specifying the Key Generator](#specifying-the-key-generator)
- [Specifying the User Agent Parser](#specifying-the-user-agent-parser)
- [Helper Methods](#helper-methods)
- [Visits](#visits)
- [Find by URL Key](#find-by-url-key)
Expand Down Expand Up @@ -100,14 +102,18 @@ php artisan migrate
```

## Usage

### Building Shortened URLs

#### Quick Start
The quickest way to get started with creating a shortened URL is by using the snippet below. The ``` ->make() ``` method

The quickest way to get started with creating a shortened URL is by using the snippet below. The `->make()` method
returns a ShortURL model that you can grab the shortened URL from.

```php
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
use AshAllenDesign\ShortURL\Classes\Builder;

$shortURLObject = $builder->destinationUrl('https://destination.com')->make();
$shortURLObject = app(Builder::class)->destinationUrl('https://destination.com')->make();
$shortURL = $shortURLObject->default_short_url;
```

Expand All @@ -120,9 +126,9 @@ You may wish to define a custom key yourself for that URL that is more meaningfu
do this by using the ``` ->urlKey() ``` method. Example:

```php
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
use AshAllenDesign\ShortURL\Classes\Builder;

$shortURLObject = $builder->destinationUrl('https://destination.com')->urlKey('custom-key')->make();
$shortURLObject = app(Builder::class)->destinationUrl('https://destination.com')->urlKey('custom-key')->make();
$shortURL = $shortURLObject->default_short_url;

// Short URL: https://webapp.com/short/custom-key
Expand All @@ -147,17 +153,19 @@ If you want to override whether if tracking is enabled or not when creating a sh
This method accepts a boolean but defaults to ``` true ``` if a parameter is not passed.

The example below shows how to enable tracking for the URL and override the config variable:

```php
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
use AshAllenDesign\ShortURL\Classes\Builder;

$shortURLObject = $builder->destinationUrl('https://destination.com')->trackVisits()->make();
$shortURLObject = app(Builder::class)->destinationUrl('https://destination.com')->trackVisits()->make();
```

The example below shows how to disable tracking for the URL and override the default config variable:

```php
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
use AshAllenDesign\ShortURL\Classes\Builder;

$shortURLObject = $builder->destinationUrl('https://destination.com')->trackVisits(false)->make();
$shortURLObject = app(Builder::class)->destinationUrl('https://destination.com')->trackVisits(false)->make();
```

##### Tracking IP Address
Expand All @@ -167,9 +175,9 @@ If you want to override whether if IP address tracking is enabled or not when cr

The example below shows how to enable IP address tracking for the URL and override the default config variable:
```php
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
use AshAllenDesign\ShortURL\Classes\Builder;

$shortURLObject = $builder->destinationUrl('https://destination.com')->trackVisits()->trackIPAddress()->make();
$shortURLObject = app(Builder::class)->destinationUrl('https://destination.com')->trackVisits()->trackIPAddress()->make();
```

##### Tracking Browser & Browser Version
Expand All @@ -180,16 +188,16 @@ but defaults to ``` true ``` if a parameter is not passed.

The example below shows how to enable browser name tracking for the URL and override the default config variable:
```php
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
use AshAllenDesign\ShortURL\Classes\Builder;

$shortURLObject = $builder->destinationUrl('https://destination.com')->trackVisits()->trackBrowser()->make();
$shortURLObject = app(Builder::class)->destinationUrl('https://destination.com')->trackVisits()->trackBrowser()->make();
```

The example below shows how to enable browser version tracking for the URL and override the default config variable:
```php
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
use AshAllenDesign\ShortURL\Classes\Builder;

$shortURLObject = $builder->destinationUrl('https://destination.com')->trackVisits()->trackBrowserVersion()->make();
$shortURLObject = app(Builder::class)->destinationUrl('https://destination.com')->trackVisits()->trackBrowserVersion()->make();
```

##### Tracking Operating System & Operating System Version
Expand All @@ -200,16 +208,16 @@ methods. These methods accept a boolean but default to ``` true ``` if a paramet

The example below shows how to enable operating system name tracking for the URL and override the default config variable:
```php
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
use AshAllenDesign\ShortURL\Classes\Builder;

$shortURLObject = $builder->destinationUrl('https://destination.com')->trackVisits()->trackOperatingSystem()->make();
$shortURLObject = app(Builder::class)->destinationUrl('https://destination.com')->trackVisits()->trackOperatingSystem()->make();
```

The example below shows how to enable operating system version tracking for the URL and override the default config variable:
```php
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
use AshAllenDesign\ShortURL\Classes\Builder;

$shortURLObject = $builder->destinationUrl('https://destination.com')->trackVisits()->trackOperatingSystemVersion()->make();
$shortURLObject = app(Builder::class)->destinationUrl('https://destination.com')->trackVisits()->trackOperatingSystemVersion()->make();
```

##### Tracking Device Type
Expand All @@ -219,9 +227,9 @@ If you want to override whether if device type tracking is enabled or not when c

The example below shows how to enable device type tracking for the URL and override the default config variable:
```php
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
use AshAllenDesign\ShortURL\Classes\Builder;

$shortURLObject = $builder->destinationUrl('https://destination.com')->trackVisits()->trackDeviceType()->make();
$shortURLObject = app(Builder::class)->destinationUrl('https://destination.com')->trackVisits()->trackDeviceType()->make();
```

##### Tracking Referer URL
Expand All @@ -231,9 +239,9 @@ If you want to override whether if referer URL tracking is enabled or not when c

The example below shows how to enable referer URL tracking for the URL and override the default config variable:
```php
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
use AshAllenDesign\ShortURL\Classes\Builder;

$shortURLObject = $builder->destinationUrl('https://destination.com')->trackVisits()->trackRefererURL()->make();
$shortURLObject = app(Builder::class)->destinationUrl('https://destination.com')->trackVisits()->trackRefererURL()->make();
```

#### Custom Short URL Fields
Expand Down Expand Up @@ -268,9 +276,9 @@ To create a single use shortened URL, you can use the ``` ->singleUse() ``` meth

The example below shows how to create a single use shortened URL:
```php
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
$shortURLObject = $builder->destinationUrl('https://destination.com')->singleUse()->make();
use AshAllenDesign\ShortURL\Classes\Builder;

$shortURLObject = app(Builder::class)->destinationUrl('https://destination.com')->singleUse()->make();
```

#### Enforce HTTPS
Expand All @@ -282,9 +290,9 @@ To enforce HTTPS, you can use the ``` ->secure() ``` method when building the sh

The example below shows how to create a secure shortened URL:
```php
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
$shortURLObject = $builder->destinationUrl('http://destination.com')->secure()->make();
use AshAllenDesign\ShortURL\Classes\Builder;

$shortURLObject = app(Builder::class)->destinationUrl('http://destination.com')->secure()->make();

// Destination URL: https://destination.com
```
Expand All @@ -295,9 +303,9 @@ When building a short URL, you might want to forward the query parameters sent i
Alternatively, you can also use the `->forwardQueryParams()` method when building your shortened URL, as shown in the example below:

```php
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
$shortURLObject = $builder->destinationUrl('http://destination.com?param1=test')->forwardQueryParams()->make();
use AshAllenDesign\ShortURL\Classes\Builder;

$shortURLObject = app(Builder::class)->destinationUrl('http://destination.com?param1=test')->forwardQueryParams()->make();
```

Based on the example above, assuming that the original short URL's `destination_url` was `https://destination.com`, making a request to `https://webapp.com/short/xxx?param1=abc&param2=def` would redirect to `https://destination.com?param1=test&param2=def`
Expand All @@ -308,11 +316,12 @@ By default, all short URLs are redirected with a ``` 301 ``` HTTP status code. B
the shortened URL using the ``` ->redirectStatusCode() ``` method.

The example below shows how to create a shortened URL with a redirect HTTP status code of ``` 302 ```:
```php
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();

$shortURLObject = $builder->destinationUrl('http://destination.com')->redirectStatusCode(302)->make();
```

```php
use AshAllenDesign\ShortURL\Classes\Builder;

$shortURLObject = app(Builder::class)->destinationUrl('http://destination.com')->redirectStatusCode(302)->make();
```

#### Activation and Deactivation Times

Expand All @@ -325,18 +334,18 @@ a given date and then automatically deactivate that URL when the marketing campa
The example below shows how to create a shortened URL that will be active from this time tomorrow onwards:

```php
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
$shortURLObject = $builder->activateAt(\Carbon\Carbon::now()->addDay())->make();
use AshAllenDesign\ShortURL\Classes\Builder;

$shortURLObject = app(Builder::class)->activateAt(\Carbon\Carbon::now()->addDay())->make();
```

The example below shows how to create a shortened URL that will be active from this time tomorrow onwards and then is
deactivated the day after:

```php
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
$shortURLObject = $builder->activateAt(\Carbon\Carbon::now()->addDay())
use AshAllenDesign\ShortURL\Classes\Builder;

$shortURLObject = app(Builder::class)->activateAt(\Carbon\Carbon::now()->addDay())
->deactivateAt(\Carbon\Carbon::now()->addDays(2))
->make();
```
Expand All @@ -346,9 +355,9 @@ $shortURLObject = $builder->activateAt(\Carbon\Carbon::now()->addDay())
By default, the package will use the ID of the last inserted short URL as the seed for generating a short URL's key. In some cases, you may want to use a custom seed instead. To do this, you can pass an integer to the `generateKeyUsing` method like so:

```php
$builder = new \AshAllenDesign\ShortURL\Classes\Builder();
$shortURLObject = $builder->destinationUrl('https://destination.com')
use AshAllenDesign\ShortURL\Classes\Builder;

$shortURLObject = app(Builder::class)->destinationUrl('https://destination.com')
->generateKeyUsing(12345)
->make();
```
Expand Down Expand Up @@ -385,8 +394,7 @@ For example, let's take this block of code that uses `if` when building the shor
```php
use AshAllenDesign\ShortURL\Classes\Builder;

$shortURLObject = (new Builder())
->destinationUrl('https://destination.com');
$builder = app(Builder::class)->destinationUrl('https://destination.com');

if ($request->date('activation')) {
$builder = $builder->activateAt($request->date('activation'));
Expand All @@ -401,7 +409,7 @@ This could be rewritten using `when` like so:
use AshAllenDesign\ShortURL\Classes\Builder;
use Carbon\Carbon;

$shortURLObject = (new Builder())
$shortURLObject = app(Builder::class)
->destinationUrl('https://destination.com')
->when(
$request->date('activation'),
Expand Down Expand Up @@ -600,6 +608,30 @@ To do this, you can set the connection name using the `connection` config value
'connection' => 'custom_database_connection_name',
```

#### Specifying the Key Generator

By default, Short URL uses the `AshAllenDesign\ShortURL\Classes\KeyGenerator` class to generate the keys for the short URL. However, you may want to use your own custom key generator class.

To do this, you can define the class to be used in the `short-url.php` config file like so:

```php
'url_key_generator' => \AshAllenDesign\ShortURL\Classes\KeyGenerator::class,
```

You'll just need to ensure that your custom key generator class implements the `AshAllenDesign\ShortURL\Interfaces\KeyGenerator` interface.

#### Specifying the User Agent Parser

By default, Short URL uses `whichbrowser/parser` package to parse the user agent header of the visitor when tracking visits. However, you may want to use your own custom user agent parser.

To do this, you can define the class to be used in the `short-url.php` config file like so:

```php
'user_agent_driver' => \AshAllenDesign\ShortURL\Classes\UserAgent\ParserPhpDriver::class,
```

You'll just need to ensure that your custom user agent parser class implements the `AshAllenDesign\ShortURL\Interfaces\UserAgentDriver` interface.

### Helper Methods
#### Visits
The ShortURL model includes a relationship (that you can use just like any other Laravel model relation) for getting the
Expand Down Expand Up @@ -653,7 +685,7 @@ The following example shows how to get an array of all tracking-enabled fields f
```php
$shortURL = \AshAllenDesign\ShortURL\Models\ShortURL::first();
$shortURL->trackingFields();
```
```

### Model Factories

Expand Down
Loading
Loading