I try to make selection on id in the project on the documentation (costs laravel 5.3).
routes / web.php file:
Route::get('/search/propertyprofile/{id}', [ 'uses' => 'PropertyProfileController@getPropertyProfile', 'as' => 'sh.search.propertyprofile' ]); In this route, I wrote the address as the first parameter, then I use the controller and the action and it should go to the specified view (here it’s ALL good if the view has the Hello world output code and no parameters)
Next, I create an action (with the parameters $ id and the variable $ request) in which I enter the data from the model in $ properties (where the id parameter corresponds to the $ id variable) and return to vhu (where the view parameter and the second parameter are the data from the database table $ properties)
PropertyProfileController:
use App\Property; use Illuminate\Http\Request; class PropertyProfileController extends Controller { public function getPropertyProfile($id,Request $request) { $properties = Property::where('id', $id); return view('sh.propertyprofile', ['properties' => $properties]); } } Property model (everything seems to be clear here):
class Property extends Model { protected $fillable = ['id','imagePath', 'title', 'description', ]; } In the view, I call the title and imagePath data from the $ properties variable (into which they are listed from the database table):
@extends('layouts.master') @section('content') <img src="{{ $properties->imagePath }}" alt="..." class="img-responsive"> <h3>{{ $properties->title }}</h3> @endsection Gives an error message :
Undefined property: Illuminate\Database\Eloquent\Builder::$imagePath (View: /var/www/projects/auth.laravel.com/resources/views/sh/propertyprofile.blade.php) Apache logs:
"GET /search/propertyprofile/8 HTTP/1.1" 500 43913 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0" Why does he say the variable variable imagePath ?? Please tell me where I was wrong or what is wrong with my judgment .... (did according to the documentation https://laravel.com/docs/5.4/routing#route-parameters )
$properties = Property::where('id', $id)- vp_arth