I am working with Laravel 5.6 and MySQL DB. in my application I have some form data edit link from vehicles table, My edit link is this,
" >Edit</a>
and I have vehicle images show table as uploads and relationship between Vehicle model and Upload model is like this, vehicle model
public function uploads()
{
return $this->hasMany(Upload::class);
}
upload model
public function vehicle()
{
return $this->belongsTo(Vehicle::class);
}
and my vehicle edit route is like this,
Route::get('myads/{id}/edit', [
'uses' => '\App\Http\Controllers\VehicleController@edit',
'as'=> 'vehicles.edit'
]);
My edit blade file vehicle images showing as this,
@foreach( $vehicles-> uploads as $upload)
<img id="preview"
src=""
height="200px" width="200px"/>
<input class="form-control" style="display:none" name="files[]" type="file" id="files" name="_token" value="" enctype="multipart/form-data">
<br/>
<a href="/myads//editimage">Edit Image</a>|
<a class="button is-outlined" href="/myads//delete" onclick="return confirm('Are you sure to want to delete this record?')" >Delete</a></td>
<hr>
@endforeach
@endif
but when i click above edit link I got following error,
NotFoundHttpException
No query results for model [App\Upload] 8 //8 this is vehicle id
how can I fix this problem?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire