11 months ago

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')


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

and index blade file is,

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


@forelse( $vehicles as $vehicule )

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

                            <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()}} 



                <td>No Advertisment to display.</td>


{{ $vehicles->links() }}

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.