title: Class 'App\Http\Controllers\DB' not found in Laravel 5 Controller
body: <p>I have a problem using the laravel 5 query builder for an Employee management system. Here is my EmployeesController</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers;
  
  use App\Employee;
  use Illuminate\Http\Request;
  use App\Http\Requests;
  use App\Http\Controllers\Controller;
  
  class EmployeesController extends Controller
  {
  
      public function index()
      {
          // $employees = Employee::all();
          // return view('employees.index', compact('employees'));
  
          $employees = DB::table('employees')-&gt;get();
  
          return view('employees.index', compact('employees'));
      }
  
  }
  </code></pre>
  
  <p>When i use the commented out code, the view works and i can see my employee list</p>
  
  <pre><code>$employees = Employee::all();
  return view('employees.index', compact('employees'));
  </code></pre>
  
  <p>I saw an <a href="https://stackoverflow.com/questions/30211608/class-app-http-middleware-db-not-found-when-using-middleware-in-laravel-5">answer</a> here, and i did as suggested but no luck. I added use DB; after the namespace declaration and also tried the code with </p>
  
  <pre><code>$employees = \DB::table('employees')-&gt;get();
  </code></pre>
  
  <p>but it throws another error which says Call to a member function count() on a non-object on line 6.
  I even copied the DB.php file from C:\xampp\htdocs\laravel5project\vendor\laravel\framework\src\Illuminate\Support\Facades to the App folder (C:\xampp\htdocs\laravel5project\app) but still  no luck. 
  I've also tried to explicitly give it the namespace </p>
  
  <pre><code>use Illuminate\Support\Facades\DB
  </code></pre>
  
  <p>Here is the view</p>
  
  <pre><code>@extends('layouts.default')
  @section('PageTitle', 'Employee List')
  @section('content')
  
  @if ( !$employees-&gt;count() )
      There are no Employees!
  @else    
  
  &lt;table id="tblEmployee" class="table table-striped table-bordered" cellspacing="0" width="100%"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
  
      &lt;tbody&gt;
          @foreach( $employees as $employee )
          &lt;tr&gt;             
              &lt;td&gt;{{$employee-&gt;Name}}&lt;/td&gt;
          &lt;/tr&gt;
          @endforeach
  
      &lt;/tbody&gt;
  &lt;/table&gt;
  
  @endif
  @endsection
  </code></pre>
  
  <p>What could be the problem?</p>