The error is on the view which says that
my $audio variable is not defined.
I want to show everything from the database using a foreach loop.
I tried base on paginate on the laravel documentation https://laravel.com/docs/5.7/pagination#basic-usage
My controller is below:
use Illuminate\Http\Request;
use App\Audio_lectures;
use Illuminate\Support\Facades\DB;
public function index(){
$audio = DB::table('audio_lectures')->latest()->paginate();
return view('welcome', ['audio_lectures' => $audio]);
}
The welcome view is below:
<div class="container">
<div class="row">
<table class="table table-dark">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Subject</th>
<th scope="col">Date Added</th>
<th scope="col">Download</th>
</tr>
</thead>
<tbody>
@foreach ($audio as $audio_lectures)
<tr>
<th scope="row"></th>
<td></td>
<td></td>
<td><a href="" class="btn btn-outline-light btn-sm">Download</a></td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
My route web.php is below:
Route::get('/','Audio_lecturesController@index');
I expect to show all the audio lectures from my database to my view.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire