11 months ago

How to fix NotFoundHttpException No query results for model [App\Upload] 8

Posted 11 months ago by Amalmax

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,

{{route('vehicles.edit',$vehicule->id.'/edit/')}}" >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\[email protected]',
    'as'=> 'vehicles.edit'

My edit blade file vehicle images showing as this,

@foreach( $vehicles-> uploads as $upload)
                    <img id="preview"
                         src="{{asset((isset($upload) && $upload->resized_name!='')?'images/'.$upload->resized_name:'images/noimage.png')}}"
                         height="200px" width="200px"/>
                    <input class="form-control" style="display:none" name="files[]" type="file" id="files" name="_token" value="{{ csrf_token() }}" enctype="multipart/form-data">
                    <!-- <a href="javascript:changeProfile();">Add Image</a> | -->
                    <!-- <a style="color: red" href="javascript:removeImage()">Delete</a>
                    <input type="hidden" style="display: none" value="0" name="remove" id="remove"> -->
               <a href="/myads/{{$upload->id}}/editimage">Edit Image</a>|

               <a class="button is-outlined" href="/myads/{{$upload->id}}/delete" onclick="return confirm('Are you sure to want to delete this record?')" >Delete</a></td>


but when i click above edit link I got following error,


No query results for model [App\Upload] 8  //8 this is  vehicle id

how can I fix this problem?

Please sign in or create an account to participate in this conversation.