You need to use Config from the global scope. You're in the namespace App\Http\Controllers and it tries to find Config in that namespace. You can fix it by adding a slash in front of Config::set():
I don't know if this Code or approach is correct to implement but I found this other way round to solve this issue :
Following steps are demonstrated using the example of including constant and a constant.php file in your project -
Step 1 : Add a namespace in your constant.php file (or any file respective of your project) like
<?php
namespace Forfun;
class className {
// Your code
}
?>
Step 2 : In your respective controllers and eloquent files just add the following code at the top:
<?php
use ForFun\className;
I hope it helps you guys to write more simple and cleaner code :) revert your suggestions if you find this helpful!
There is another cause for this problem. I'll post it here just in case it saves someone down the road...
I had a Laravel app working perfectly fine until at some point it started throwing this exact same error. As it turns out, the ONLY place that showed me the cause was running "composer update". The error was pretty clear:
Dotenv values containing spaces must be surrounded by quotes.
I had added something to my .env file that had spaces in it and I didn't surround it with quotes. So:
#.env
VALUE=Some spaces