I have got Laravel installed and I am trying to fetch ANY data from the SQL Server database but i keep having the same problem all the time and I am getting so frustrated because I either just don't know what I am doing or I am doing it wrong.
I've got my database connection set up after a lot of hassle with ODBC SQL Drivers for Windows. Now in my welcome.blade.php I want to fetch data from my database but everytime i try to get any data i get this error:
Fatal error: Class 'Illuminate\Support\Facades\DB' not found in C:\xampp\htdocs\resources\views\welcome.blade.php on line 9
Now I only got these two lines in my code that should fetch (I GUESS) the data:
<?php
$Booking = \Illuminate\Support\Facades\DB::table('fmsStage.dbo.Booking')->get();
var_dump($Booking);
?>
But instead it gives me that error. And I've tried using \DB::table and also tried using just the table itself \DB::table('Booking') and also with the table prefix \DB::table('dbo.Booking') but it won't even find the whole DB class. But what am I doing wrong, I don't get it at all.
When i try to add
use DB;
It gives me another error/warning:
Warning: The use statement with non-compound name 'DB' has no effect in C:\xampp\htdocs\resources\views\welcome.blade.php on line 9
UPDATE: I have now created the model Booking to get data from booking. But now when i use
use App\Booking;
$booking = App\Booking::all();
foreach($booking as $bookings) {
echo $bookings->agent;
}
It stills gives me an error on the freaking USE part...
Fatal error: Class 'app\Booking' not found in C:\xampp\htdocs\resources\views\welcome.blade.php on line 10
Thank you in advance
$data = TABLENAME::all();change table name with the name of your modeluse Illuminate\Support\Facades\DB as DB;