I am trying to set up middleware. I followed these instructions:
http://mattstauffer.co/blog/laravel-5.0-middleware-filter-style
And my code is
<?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\RedirectResponse;
class LoadVars {
$comingevents = App\Number::where('item','events')->get(array('quantity'));
I got this error:
FatalErrorException in LoadVars.php line 24: Class 'App\Http\Middleware\App\Number' not found
In models when I define relations I use App\Number and it works well.
What is the proper way of using Classes inside a middleware method?
\App\Number
, otherwise it will be interpreted relative to the namespace you are currently in, which isApp\Http\Middleware
. Or you coulduse App\Number;
at the top and then just access it withNumber::where(...);
– Quasdunk