jeudi 28 décembre 2017

Calling searchable() on Query Builder based result throws errors

How to use searcable() method on results returned by query builder. Suppose there are five tables

  1. products
  2. vendors
  3. categories
  4. vendor_products (pivot table for Products and Vendors)
  5. product_categories (pivot table for Products and Categories)

Is there a way to use searchable on the following query. return \DB::table("products") ->join('vendor_products', function ($join) { $join->on('products.id', '=', 'vendor_products.product_id') ->MANY_OTHER_WHERE_CONDITIONS }) ->join('categories', function ($join) { $join->on('category_id', '=', 'categories.id'); }) ->MANY_OTHER_CONDITIONS ->searchable() But Laraval scout return error Call to undefined method Illuminate\Database\Query\Builder::searchable()

Is there a way to upload the results of above query. I have added searcable trait on vendors, categories, and products models.

It looks like Scout only work when we have Eloquent relationship returned from the query and don't work on query builder.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2C32E3N
via IFTTT

Aucun commentaire:

Enregistrer un commentaire