They're taken care of by Taylor in vendor folder.
Why do facades work in blade templates without being declared in use?
In a Blade template I can do:
{{ Storage::url('file.jpg') }}
And it will output the storage URL of the file.
However in my controller if I do:
echo Storage::url('file.jpg')
I get "Class 'App\Http\Controllers\Admin\Storage' not found"
In order for it to work in the controller I have to:
use Illuminate\Support\Facades\Storage;
Why does Blade have access to the Storage facade without this, but the controller doesn't?
Its because in your Classes you have declared a namespace. This says that unless otherwise stated all the classes mentioned in the file are in the same namespace.
So, in the class declaring its namespace App\Http\Controllers, Log is assumed to be App\Http\Controllers\Log
As you have noted, we use \Log to alias the Log class so that it is clear its in the root namespace
So, why not for views?
The difference here is that the blade files are not inside a namespaced class. Everything is assumed to be in the root namespace, so no import is necessary
Please or to participate in this conversation.