I'm starting to learn Laravel, but not surprisingly, I'm bumping into problems. This one I know is basic, but I can't solve. I'm trying to make a simple SELECT from the database but it shows nothing!
This is the code
web.php
Route::get('list', ['uses' => 'robotController@index']);
robotController
public function index()
{
$robots = DB::select('select * from robots where Name = ?', [1]);
return view('ListaRobots', ['robots' => $robots]);
}
listaRobots.blade.php
@foreach ($robots as $robot) {{ $robot['Name'] }} @endforeach
I'm trying to make a foreach that gets the "Name" of all the robots but I can't get anything. The screen goes all blank. But I have two entries in the robots table. I have changed the .env to connect to the DB, and managed to use seed to create entries in the table but cant make queries.
1. - tkausl