Ryan B
Ryan B

Reputation: 108

Redirecting all pages in laravel

Ok So I have a simple page with not many functions as I have been working on the front end but I am now ready to start implementing features and the first feature I want to put in is where a certified admin could press a button on the page and it makes every page redirect to a page that says the site is in maintenance mode Now I already have the Authentication sorted out for the admin and auth is used. What could I do?

Upvotes: 0

Views: 1380

Answers (1)

Cyril
Cyril

Reputation: 3148

Create this route:

Route::get('/down', function(){
    Artisan::call('down');
});

And then create a button in a view that leads to '/down'. Your website will turn to maintenance mode.

You might want to protect that route with a middleware. To go back to normal mode, you'll have to execute php artisan up in the terminal, since all the website will be frozen.

Upvotes: 2

Related Questions