Msoft
11 months ago
259
23
Laravel

Method links does not exist in Laravel 5.6 app?

Posted 11 months ago by Msoft

working with laravel 5.6 and in My comtroller I have two tables like vehicles and uploads.relationship with both two tables are, Vehicle Model,

public function uploads()
    {
        return $this->hasMany(Upload::class);
    }

and Upload Model,

 public function vehicle()
    {
        return $this->belongsTo(Vehicle::class);
    }

and I have following index function in My VehicleController,

$vehicles = Vehicle::with('uploads')
            ->orderBy('adtype','DESC')

            ->latest('updated_at')
            ->paginate(5);

            return view('vehicles.index')->withVehicles($vehicles);

and index blade file is,

<form method="GET" action="{{ url('search') }}">
      {{csrf_field()}}
            <div class="row">
                <div class="col-md-6">
                    <input type="text" name="search" class="form-control" placeholder="Search">
                </div>
                <div class="col-md-6">
                    <button class="btn btn-info">Search</button>
                </div>
            </div>
        </form>

        <br> 

@forelse( $vehicles as $vehicule )


                    @if( $vehicule->uploads->count() > 0 )
                        <a href="{{ route('vehicles.show', $vehicule->id) }}">
                            @php
                                $upload = $vehicule->uploads->sortByDesc('id')->first();
                            @endphp

                            <div style="border-style: solid; background-color: {{ $vehicule->adtype === 1 ? '#FFEFD5' : '#FFFFFF' }} ">
                            <img src="/images/{{ $upload->resized_name }}" height="150" width="250"></a>


                        {{ Carbon\Carbon::parse($vehicule->created_at)->diffForHumans()}} 
                            {{$vehicule->provincename}}
                          {{$vehicule->milage}}

                          </div>
<br>
                           <hr>

                    @endif

            @empty
                <td>No Advertisment to display.</td>
            @endforelse

</div>

</div>
</div>
{{ $vehicles->links() }}
</div>
@endsection

my pagination is working fine, but in my index file I have search input using algolia. when I use keyword and click search button following error is occured,

(2/2) ErrorException

Method links does not exist. (View: C:\Users\banda\Desktop\ddddd\resources\views\vehicles\index.blade.php)

how can fix this problem?

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