I am creating a library that uses \Illuminate\Support\Facades\DB
to reference the database. I'm getting the following exception on the call to DB::table()->where()->get()
: "ReflectionException: Class db does not exist." What is the problem and what do I need to do to overcome it?
I know that there is a process using \Illuminate\Database\Capsule\Manager
to establish a connection to the database. But I haven't found any example on how to make this work with \Illuminate\Support\Facades\DB
.
Code sample:
use \Illuminate\Support\Facades\DB;
abstract class Data
{
public static function tables($prefix, $mode=null)
{
$outbound = array();
$tables = DB::table('information_schema.tables')->where('TABLE_NAME', 'LIKE', $prefix.'_%')->get();
foreach ($tables as $table) {
...
}
return $outbound;
}
}
Stack trace:
~/vendor/laravel/framework/src/Illuminate/Container/Container.php:749
~/vendor/laravel/framework/src/Illuminate/Container/Container.php:644
~/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:709
~/vendor/laravel/framework/src/Illuminate/Container/Container.php:1203
~/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:175
~/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:144
~/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:231
~/Data.php:XXX