Reputation: 2833
I have got option to disable/enable registration of users. Where should i store this data? What is the best practise?
I think, that store this little data in DB is not good solution.
Upvotes: 3
Views: 2393
Reputation: 7474
In that case, you can just add this line inside your registration function
return redirect()->back();
So, that user will not be able to see registration page. and when you want to enable it again, you can comment the above line and you're good to go.
Upvotes: 2
Reputation: 1852
Hope you know the concept of Environment Variables
In Laravel its stored in .env.php file
<?php
return [
'user_registration' => 'enable/disable'
];
?>
You can retrieve the value as
$_ENV['user_registration']
And manipulate the function accordingly. For ex. if enable then show the form else hide it from Views
Documentation:
http://laravel.com/docs/4.2/configuration#environment-configuration
Upvotes: 4
Reputation: 5791
Ideally, you would want to flip the switch on registration of users on an admin panel. I.e, create a user interface and set a value in a table somewhere in a far away database.
The easiest way however, is simply to create a config file.
My laravel deployments come with a 'website' config, where i place all the website's related configuration values in it.
Steps:
Create a configuration file: config/website.php
In the website.php
file:
return [
'registration' => true
];
In your controllers, simply add if(\Config::get('website.registration'))
to check whether user registration is on/off.
Source: http://laravel.com/docs/5.0/configuration
Upvotes: 1