There is a Search page (1) I click on the selected item and go to the propertyprofile page (2). I get this error when going:
Undefined index: imagePath(View: /var/www/projects/auth.laravel.com/resources/views/sh/propertyprofile.blade.php) routes / web.php file:
Route::get('/search', [ 'uses' => 'SearchController@getSearch', 'as' => 'sh.search' ]); Route::get('/search/propertyprofile', [ 'uses' => 'PropertyProfileController@getPropertyProfile', 'as' => 'sh.search.propertyprofile' ]); SearchController and PropertyProfileController files:
class SearchController extends Controller { public function getSearch() { $properties = Property::all(); return view('sh.search', ['properties' => $properties]); } } class PropertyProfileController extends Controller { public function getPropertyProfile() { $properties = Property::all(); return view('sh.propertyprofile', ['properties' => $properties]); } } Property model:
class Property extends Model { protected $fillable = ['imagePath', 'title', 'description', 'price', 'id']; } search.blade.php:
@extends('layouts.master') @section('content') @foreach($properties->chunk(4) as $propertyChunk) <div class="row"> @foreach($propertyChunk as $property) <div class="col-md-3"> <img src="{{ $property->imagePath }}" alt="..." class="img-responsive"> <h3>{{ $property->title }}</h3> <a href="{{ route('sh.search.propertyprofile') }}">Property Profile</a> </div> @endforeach </div> @endforeach @endsection file propertyprofile.blade.php:
@extends('layouts.master') @section('content') <img src="{{ $properties['imagePath'] }}" alt="..." class="img-responsive"> <h3>{{ $properties['title'] }}</h3> <!-- <p> Hello world! </p> --> @endsection And when in propertyprofile.blade.php in @section you write just Hello world, then it goes without problems ... Help me figure it out, because I’m equally lifting values from an array in two views .... WHAT is wrong with me?
