I am trying to use DB
class to run query. I have used it in my controller like this:
use \DB;
And I am using it in my code like this:
$changeCar = DB::select(DB::raw($query));
I have tried including it like this:
use Illuminate\Support\Facades\DB
But still the same. Also, tried it with the backslash in the code and not including it like this:
$changeCar = \DB::select(\DB::raw($query));
My Code:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use \DB;
class TicketsController extends Controller
{
public function myTickets()
{
$user = Auth::user();
$changeCar = DB::select(DB::raw($query));
}
}
Still the same. What am I doing wrong here? Any help?
P.S: My laravel
version is 5.4.33
DB
is a facade in Laravel. So just doing Use DB;
should work. Can you check if you have opcache
enabled on your php.ini ?
Look up php.ini
for opcache_enabled=1
and change the value to 0. Then restart your nginx/apache server and try again.