How to make a constant and use globally in laravel?

0 votes
Hello everyone,

Can anyone help me out that how can i create constant and use it globally in laravel?
Mar 24 in Laravel by kartik
• 27,360 points
93 views

1 answer to this question.

0 votes

Hii,

You can create a constants.php page in config folder if does not exist. Now you can put constant variable with value here and can use with Config::get('constants.VaribleName');

Example

return [ 'ADMINEMAIL' => 'info@bestinterviewquestion.com', ];

Now we can display with

Config::get('constants.ADMINEMAIL');

Hope this is helpful!

Thank you!!

answered Mar 24 by Niroj
• 58,920 points

Related Questions In Laravel

0 votes
1 answer

How to mock a static facade methods in Laravel?

Hey, Facades provide a "static" interface to classes ...READ MORE

answered Mar 19 in Laravel by Niroj
• 58,920 points
500 views
0 votes
1 answer

Explain validations in laravel and How to validate my application incoming data?

Hey @kartik, In Programming validations are a handy ...READ MORE

answered Mar 23 in Laravel by Niroj
• 58,920 points
107 views
0 votes
1 answer

What is database migration and how to create database migration in Laravel?

Hii, Migrations are like version control for your database, ...READ MORE

answered Mar 23 in Laravel by Niroj
• 58,920 points
152 views
0 votes
1 answer

.How to turn off CSRF protection for a particular route in Laravel?

Hey, We can add that particular URL or ...READ MORE

answered Mar 24 in Laravel by Niroj
• 58,920 points
739 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18 in Laravel by Niroj
• 58,920 points
2,185 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18 in Laravel by Niroj
• 58,920 points
241 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23 in Laravel by Niroj
• 58,920 points
189 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23 in Laravel by Niroj
• 58,920 points
2,721 views
0 votes
1 answer

How to make a new page with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18 in Laravel by Niroj
• 58,920 points
147 views
0 votes
1 answer

How to pass data through URL and access through controller in Laravel?

Hello, You can  first refer how to  Create controller through ...READ MORE

answered Mar 18 in Laravel by Niroj
• 58,920 points
1,736 views