Support the ongoing development of Laravel.io →
Input Database Forms
Last updated 1 year ago.
0

I think you're looking for the faceted search ? do a google search for "laravel facet search" and there are many tutorials.

0

I think this will solve it:

{{{ $result['name'] }}}

on /vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php

/**
 * Execute the query as a "select" statement.
 *
 * @param  array  $columns
 * @return array|static[]
 */
public function get($columns = array('*'))
{
	return $this->getFresh($columns);
}

As written there, this function returns array.

Last updated 8 years ago.
0

In your view you are looking for a variable called $results which is not set. When you are creating your view you are only passing through one variable called $products in your code: return view('search')->with('products', $results);

Either change your return to be return view('search')->with('results', $results); or update your view to use $products rather than $results.

Let me know if you need more help :-)

Last updated 8 years ago.
0

Hey thanks for replying :) . I changed it but i cant get the results. The view says either Undefined index: name or if I have it like $product->name it says call to non object. Any ideas?

Last updated 8 years ago.
0

I would be interested in seeing a var_dump of $results because from what I can see it should be working unless I have forgotten some idiosyncrasy of how Laravels query builder returns results.

0

Does your view (blade template) now look like this maneesaj?


<?php
   if(isset($products)){ ?>
  @foreach($products as $product)
   {{{ $product->name }}}
 @endforeach
  <?php } else {
  echo "products not set";
  }
?>

(I've kept similar to your original code, simply substituting $results and $result for $products and $product. You could clean a little more using blade syntax for the if/else statements.)

0

Hey Thanks for the replies. I managed to fix it, it was an issue with the database migrations. Thanks for your help :).

0

Match your controller and view files with the one given here: https://laravel.io/forum/06-05-2015-newbie-trying-to-create-a-... This is a working tutorial on create live search in Laravel 5.5. Basic things should be the same. This could work for you as well. Try out.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

maneesaj maneesaj Joined 28 Feb 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.