Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel - where to store site config data

Tags:

laravel

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.

like image 561
Tadeáš Jílek Avatar asked Dec 02 '25 06:12

Tadeáš Jílek


2 Answers

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

like image 148
Ajay Kumar Ganesh Avatar answered Dec 04 '25 00:12

Ajay Kumar Ganesh


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.

like image 43
Gaurav Dave Avatar answered Dec 03 '25 23:12

Gaurav Dave



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!