

GitHub - larsjanssen6/underconstruction: This Laravel package makes it possible...
source link: https://github.com/larsjanssen6/underconstruction
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Laravel Under Construction
This Laravel package makes it possible to set your website in "Under Construction" mode. Only users with the correct 4 digit code can access your site. This package can for example be useful to show your website to a specific client. Everything works out of the box, and it's fully customizable.
If you appreciate my work please give this repo a star or buy me a coffee ^ .
Installation
Begin by installing this package through Composer (Laravel 6, 7, 8 and 9 compatible!).
composer require larsjanssen6/underconstruction
The \LarsJanssen\UnderConstruction\UnderConstruction::class
middleware must be registered in the kernel:
//app/Http/Kernel.php
protected $routeMiddleware = [
// ...
'under-construction' => \LarsJanssen\UnderConstruction\UnderConstruction::class,
];
Defaults
Publish the default configuration file.
php artisan vendor:publish
# Or...
php artisan vendor:publish --provider="LarsJanssen\UnderConstruction\UnderConstructionServiceProvider"
This package is fully customizable. This is the content of the published config file under-construction.php
:
<?php
return [
/*
* Activate under construction mode.
*/
'enabled' => env('UNDER_CONSTRUCTION_ENABLED', true),
/*
* Hash for the current pin code
*/
'hash' => env('UNDER_CONSTRUCTION_HASH', null),
/*
* Under construction title.
*/
'title' => 'Under Construction',
/*
* Custom Route Prefix
* */
'route-prefix' => env('UNDER_CONSTRUCTION_ROUTE_PREFIX','under'),
/*
* Custom Endpoint if you don't want to use 'construction'
* e.g. if you change to 'checkpoint', the route prefix
* above will be appended giving you 'under/checkpoint'
* */
'custom-endpoint' => env('UNDER_CONSTRUCTION_CUSTOM_ENDPOINT','construction'),
/*
* Back button translation.
*/
'back-button' => 'back',
/*
* Show button translation.
*/
'show-button' => 'show',
/*
* Hide button translation.
*/
'hide-button' => 'hide',
/*
* Show loader.
*/
'show-loader' => true,
/*
* Redirect url after a successful login.
*/
'redirect-url' => '/',
/*
* Enable throttle (max login attempts).
*/
'throttle' => true,
/*
|--------------------------------------------------------------------------
| Throttle settings (only when throttle is true)
|--------------------------------------------------------------------------
|
*/
/*
* Set the amount of digits (max 6).
*/
'total_digits' => 4,
/*
* Set the maximum number of attempts to allow.
*/
'max_attempts' => 3,
/*
* Show attempts left.
*/
'show_attempts_left' => true,
/*
* Attempts left message.
*/
'attempts_message' => 'Attempts left: %i',
/*
* Too many attempts message.
*/
'seconds_message' => 'Too many attempts please try again in %i seconds.',
/*
* Set the number of minutes to disable login.
*/
'decay_minutes' => 5,
/*
* Prevent the site from being indexed by Robots when locked
*/
'lock_robots' => true,
];
Usage
You'll have to set a 4 digit code (you can change this up to 6 in config file). You can do that by running this custom
artisan command (in this example the code is 1234
,you can obviously set another code). It
will generate a hash that will be stored in your .env
file.
php artisan code:set 1234
You can set routes to be in "Under Construction" mode by using the under-construction
-middleware on them.
Route::group(['middleware' => 'under-construction'], function () {
Route::get('/live-site', function() {
echo 'content!';
});
});
Changelog
Please see CHANGELOG for more information on what has changed recently.
Testing
composer test
Contributing
I would love to hear your ideas to improve my codeing style and conventions. Feel free to contribute.
Security
If you discover any security related issues, please email [email protected]. You can also make an issue.
Credits
About me
I'm Lars Janssen from The Netherlands and like to work on web projects. You can follow me on Twitter.
License
The MIT License (MIT). Please see License File for more information.
Open-Source Software - Give 
We have included the awesome symfony/thanks
composer package as a dev
dependency. Let your OS package maintainers know you appreciate them by starring
the packages you use. Simply run composer thanks after installing this package.
(And not to worry, since it's a dev-dependency it won't be installed in your
live environment.)
Recommend
-
238
Laravel QueryLine Introduction QueryLine is a laravel package to show time graph against run queries on a page thereby allowing to see which are slow/fast queries running on the page. Screenshot Requirements...
-
199
-
16
:package_description Note: Run ./configure-skeleton to get started, or manually replace :author_name :author_username :author_email :vendor_name
-
9
Blade Icons A package to easily make use of SVG icons in your Laravel Blade views. Originally "Blade SVG" by Adam Wathan. Looking for a specific icon? Try our icon search:
-
13
Trackable Jobs For Laravel This package allows you to track your laravel jobs! Using this package, you can easily persist the output and the status of any job in your application. Installation To install this package...
-
16
This package gives you a set of conventions to make the most out of Hotwire in Laravel (inspired by the turbo-rails gem). There is a
-
8
Laravel Auto Routes _ _____ _ /\ | | | __ \ | | / \ _ _| |_ ___ ______| |__) |___ _ _| |_ ___ ___ / /\ \|...
-
10
Laravel Email Domain Rule This package allows to define a subset of allowed email domains and validate any user registration form with a custom rule. Installation You can install the package via composer:
-
7
Laravel Shopify App A full-featured Laravel package for aiding in Shopify App development, similar to shopify_app for Rails. Works for Laravel 7 and up. Table of Contents * Wiki...
-
9
Blade components for easy image manipulation and file downloads This package makes it possible to serve images from anywhere, this might be a public path , a private path or a Laravel disk
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK