Skip to content

Commit

Permalink
Merge pull request #3 from shitware-ltd/feat-configurable-redirect-time
Browse files Browse the repository at this point in the history
added configuration
  • Loading branch information
arkoe authored Oct 4, 2022
2 parents f30af03 + 85747c4 commit c71ded2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ We believe in backwards compatability just as much as Trongate, below are the su
composer require shitware-ltd/laravel-trongate
```

## Configuration

We understand that the default countdown of `5` seconds and `1` second delay before redirect might not suit your needs.

To fix this, publish the configuration file and modify just to your needs!

```bash
php artisan vendor:publish --provider="ShitwareLtd\LaravelTrongate\TrongateServiceProvider" --tag="config"
```

## License

MIT
Expand Down
8 changes: 7 additions & 1 deletion src/TrongateServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@ class TrongateServiceProvider extends ServiceProvider
{
public function register()
{

$this->mergeConfigFrom(__DIR__.'./config/trongate.php', 'trongate');
}

public function boot(Kernel $kernel)
{
$this->loadViewsFrom(__DIR__.'/resources/views', 'trongate');
$kernel->pushMiddleware(TrongateMiddleware::class);

if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__.'/config/trongate.php' => config_path('trongate.php'),
], 'config');
}
}
}
14 changes: 14 additions & 0 deletions src/config/trongate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Countdown
|--------------------------------------------------------------------------
|
| Who doesn't love a good ol' countdown? Specify the time (in seconds)
| we should be counting down before redirecting the visitor.
|
*/
'countdown' => 5,
];
8 changes: 7 additions & 1 deletion src/resources/views/trongate.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
<h1>You've made a <u>huge</u> mistake for using Laravel.</h1>
<h2>Use Trongate!</h2>

<p>You will be redirected in <span _="on load set $timer to 5 repeat 5 times decrement $timer then put it into my innerHTML wait 1s end then go to url 'https://trongate.io'">5</span> seconds.</p>
<p>
You will be redirected in
<span _="on load set $timer to {{ config('trongate.countdown') }} repeat {{ config('trongate.countdown') }} times decrement $timer then put it into my innerHTML wait 1s end then go to url 'https://trongate.io'">
{{ config('trongate.countdown') }}
</span>
seconds.
</p>
</body>
</html>

0 comments on commit c71ded2

Please sign in to comment.