I'm trying to pass a variable from a controller route to a view so i can display data relating to new assoicate model. It's working for other contrllers, but i can't figure out why it's not here.
Controller @Index - Not passing down
public function index(){
$Advert = new PropertyAdvert();
return view('pages/Advert/index', compact('Advert'));
}
@Show - Is working, this is just an example.
public function show($id){
$user = Auth::user();
$Advert = PropertyAdvert::where('id', $id)->first();
return view('pages/Advert/show', compact('Advert', 'user'));
}
This is the route
Route::get('/property', 'AdvertisementController@index');
Route::get('/advertise', 'AdvertisementController@create')->middleware('auth');
Route::post('/createadvert', 'AdvertisementController@store');
Route::get('/property/{id}', 'AdvertisementController@show');
This is the template i'm trying to pass down to show.blade.php
<div class="row text-center" style="display:flex; flex-wrap:wrap">
<div class="col-lg-12">
<h3>Our most recent properties</h3>
@foreach ($Advert as $property)
<div class="col-md-3 col-sm-6">
<div class="thumbnail">
<img src="data:image/gif;base64,">
<div class="caption">
<h4></h4>
</div>
<p>
<a href="#" class="btn btn-primary">More Info!</a>
</p>
</div>
</div>
@endforeach
</div>
</div>
</div>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire