Method Illuminate\Database\Eloquent\Collection::appends does not exist. 1




This error occurs due to the missing sortable function sortable() in the controller. 

Step 1:

Open your view (blade) file where you are using sortable to sort the column of the table. Check if the sortable code is correct. For example, if my view file name is product.blade.php It should be like:


            @sortablelink('id',__('S No')) 
            @sortablelink('name',__('Product Name'))  

Step 2:
Now open your Controller file which is loading your view file, for example, it can be like ProductController.php

Check the function which is loading the view file product.blade.php which can be like function index(). It should use sortable function to fetch data from the database.



class ProductController extends Controller
    public function index()
        $title = "Product Page";

        return view('product.list',compact('title','product'));


Step 3:

Now open your Model file which should be like Product.php

Its code should have a Sortable line. If its missing add it like below:



namespace App;

use Illuminate\Database\Eloquent\Model;
use Kyslik\ColumnSortable\Sortable;
class Product extends Model
    use Sortable;

    protected $guarded=[];

    public $sortable = ['id','name','price'];


Now refresh the browser to see your list of the view page.