You need to import the facade class instead
use Illuminate\Support\Facades\DB;
Hello All,
First i have a helpers folder and my custom class, i want use DB facade in class but i cant, when i try run the code, that gives me Fatal error: Class 'DB' not found in
What's wrong in this code ?
<?php
namespace AnkaTech\Helpers;
use DB;
class Helper{
public static function settings($columnName){
$setting = DB::table("settings")->where("id",1)->get();
return $setting->{$columnName};
}
}
It looks as though one of the dependencies hasn't been loaded correctly. Like @bestmomo has suggested, remove your /vendor folder and try re-installing your composer dependencies?
If that doesn't seem to work, I'd suggest looking at the underlying dependencies to see if there's a version mis-match or your version of php doesn't support x, or x isn't enabled. It could be something really simple but not obvious.
Please or to participate in this conversation.