Есть страница Search (1) кликаю на выбранный элемент и перехожу на страницу propertyprofile (2). У меня выдает такую ошибку при переходе:
Undefined index: imagePath(View: /var/www/projects/auth.laravel.com/resources/views/sh/propertyprofile.blade.php)
файл routes/web.php:
Route::get('/search', [
'uses' => 'SearchController@getSearch',
'as' => 'sh.search'
]);
Route::get('/search/propertyprofile', [
'uses' => 'PropertyProfileController@getPropertyProfile',
'as' => 'sh.search.propertyprofile'
]);
Файлы SearchController и PropertyProfileController:
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 :
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
файл 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
А когда в propertyprofile.blade.php в @section пишешь просто Hello world, тогда переходит без проблем... Помогите разобраться, ведь я же в двух вьюхах одинаково подтягиваю значеня из массива.... ЧТО у меня не так?