title: Laravel Searchbar Class 'products' not found / ProductController@?
body: <p>I am an Laravel beginnner and try now to build an Simple Searchbar on my site.</p>
  
  <p>But I get this error: </p>
  
  <blockquote>
    <p>Class 'products' not found</p>
  </blockquote>
  
  <p>Can someone tell me please what I have forget in my Controllers?</p>
  
  <p><strong>Search form on Index:</strong></p>
  
  <pre><code> &lt;ul class="searchbar"&gt;
      &lt;form action="/search" class="light" method="POST" role="search"&gt;
   {{ csrf_field() }}
          &lt;input type="text" class="form-control" name="q" placeholder="Find your item" /&gt;
          &lt;input type="submit" value="Search" /&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p><strong>search.blade.php:</strong></p>
  
  <pre><code>@extends('master.main')
  
  @if(Auth::check())
  
  @section('main-content')
  
    @component('master.notification')
  
      @slot('size')
  
      col-md-8 col-md-offset-2
  
      @endslot
  
      @slot('title')
  
      Product Search
  
      @endslot
  
      &lt;div class="container"&gt;
      @if(isset($products))
      &lt;h2&gt;Product Search&lt;/h2&gt;
          &lt;table class="table table-striped"&gt;
              &lt;thead&gt;
                  &lt;tr&gt;
                      &lt;th&gt;Product&lt;/th&gt;
                      &lt;th&gt;Description&lt;/th&gt;
                  &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;tbody&gt;
                  @foreach($products as $dummy)
                  &lt;tr&gt;
                      &lt;td&gt;{{$dummy-&gt;name}}&lt;/td&gt;
                      &lt;td&gt;{{$dummy-&gt;description}}&lt;/td&gt;
                  &lt;/tr&gt;
                  @endforeach
  
              &lt;/tbody&gt;
          &lt;/table&gt;
          {!! $products-&gt;render() !!}@endif
      &lt;/div&gt;
          &lt;div class="container"&gt;
              @if(isset($details))
              &lt;p&gt; The Search results for &lt;b&gt; {{ $query }} &lt;/b&gt; are :&lt;/p&gt;
              &lt;h2&gt;Product Search&lt;/h2&gt;
              &lt;table class="table table-striped"&gt;
                  &lt;thead&gt;
                      &lt;tr&gt;
                          &lt;th&gt;Product&lt;/th&gt;
                          &lt;th&gt;Description&lt;/th&gt;
                      &lt;/tr&gt;
                  &lt;/thead&gt;
                  &lt;tbody&gt;
                      @foreach($details as $products)
                      &lt;tr&gt;
                          &lt;td&gt;{{$products-&gt;name}}&lt;/td&gt;
                          &lt;td&gt;{{$products-&gt;description}}&lt;/td&gt;
                      &lt;/tr&gt;
                      @endforeach
                  &lt;/tbody&gt;
              &lt;/table&gt;
  
              @if($details){!! $details-&gt;render() !!}@endif
              @elseif(isset($message))
              &lt;p&gt;{{ $message }}&lt;/p&gt;
              @endif
          &lt;/div&gt;
  
    @endcomponent
  
  @stop
  
  @endif
  </code></pre>
  
  <p><strong>web.php:</strong></p>
  
  <pre><code>Route::get ( '/', function () {
      $mydatabase = products::paginate(25);
      return view ( 'search' )-&gt;withproducts($mydatabase);
  } );
  
  Route::any ( '/search', function () {
      $q = Input::get ( 'q' );
      if($q != ""){
      $products = products::where ( 'name', 'LIKE', '%' . $q . '%' )-&gt;orWhere ( 'description', 'LIKE', '%' . $q . '%' )-&gt;paginate (5)-&gt;setPath ( '' );
      $pagination = $products-&gt;appends ( array (
                  'q' =&gt; Input::get ( 'q' ) 
          ) );
      if (count ( $products ) &gt; 0)
          return view ( 'search' )-&gt;withDetails ( $products )-&gt;withQuery ( $q );
      }
          return view ( 'search' )-&gt;withMessage ( 'No Products found. Try to search again !' );
  } );
  </code></pre>
  
  <p><strong>The error comes from:</strong></p>
  
  <blockquote>
    <p>Route::get ( '/', function () {
        $mydatabase = products::paginate(25);</p>
  </blockquote>
  
  <p>How is <code>products</code> or <code>Product::paginate</code> defined or must I use in <code>web.php</code> the <code>ProductController@...</code>? Yes, I have found out its not my database table <code>products</code> ;) I think <code>Product</code> instead of <code>products</code> are correct, right?</p>
  
  <p><strong>/App/Product.php:</strong></p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  use Storage;
  
  class Product extends Model
  {
      public function category(){
        return $this-&gt;belongsTo('App\Category');
      }
      public function seller(){
        return $this-&gt;belongsTo('App\User');
      }
      public function buyer(){
        return $this-&gt;belongsTo('App\User');
      }
  
      public function bids(){
        return $this-&gt;hasMany('App\Bid');
      }
      public function purchases(){
        return $this-&gt;hasMany('App\Purchase');
      }
  
  
  
  }
  </code></pre>