2

How to create function to show result in list? - Backpack

This code return error {message: "Call to a member function count() on array", exception: "Error",…} exception: "Error" file: "location/crm/vendor/backpack/crud/src/app/Library/CrudPanel/Traits/Query.php" line: 144 message: "Call to a member function count() on array" trace: [,…]

 $this->crud->addFilter([ // select2 filter
        'name' => 'version',
        'type' => 'select2',
        'label'=> 'Status'
      ], function() {
          return [
            'something1' => 'something1',
            'something2' => 'something2',
        ];
      }, function($value) {
        //dump($this->crud);
        $query = DB::select("SELECT s.system_id FROM(
            SELECT s.id as system_id, (SELECT max(id) FROM licenses l WHERE s.id = l.system_id) as license_id FROM systems s
        ) s LEFT JOIN licenses l ON l.id = s.license_id WHERE l.version= '$value' ORDER BY s.system_id");



        return $this->crud->query = $query;
      });
RosheD
  • 33
  • 6
  • The Backpack List operation only works with Eloquent, not DB results. You should rewrite your db statement using Eloquent for it to work. – tabacitu May 19 '20 at 08:16

1 Answers1

0

There is something about custom filter ; https://github.com/Laravel-Backpack/CRUD/issues/83

You can follow that discussion's samples, for creating your own filter method.

Or here is smilar question : Filter table with a column in Laravel Backpack

Or maybe, pivot table samples ;) backpack crud filters by pivot table

Fatih Toprak
  • 1,097
  • 1
  • 19
  • 48