Why App\Http\Controllers\DB and Model Classes Fail in Laravel 5
Seeing Class 'App\Http\Controllers\DB' not found immediately tells you that your application is resolving the static facade to a file in the wrong namespace. This specific error message is a hallmark of how Laravel's autoloading worked prior to version 4, or when a custom service provider was left over from an older architecture. In a fresh Laravel 5 installation, the DB class is a facade that proxies calls to the database manager located in the root namespace, not inside App\Http\Controllers.
The error occurs because the autoloader attempts to find a concrete implementation of DB within the App\Http\Controllers directory based on the legacy naming convention. In modern Laravel versions, facades like DB, Cache, and Auth reside in the Illuminate\Support\Facades namespace. They are thin wrappers that delegate to service providers registered in your application's bootstrap process. If you are seeing this error after cloning an old project or switching environments, it often indicates that the composer autoloader needs a refresh or that a custom facade definition file is incorrectly overriding the default behavior.
To resolve this, ensure your composer.json reflects the version of Laravel you are actually running. If you have been using the DB facade for years in L4, switching to L5 requires no code changes, but the underlying mechanism has shifted from a static class in a controller folder to a facaded service. Run php artisan config:clear and composer dump-autoload to ensure the autoloader recognizes the updated namespace mappings without relying on legacy path definitions.
Defining Your Own Model Class
The second issue regarding your Quotation model stems from a similar namespacing confusion, but with a specific twist involving the class name and file location. You defined the class in the root of the App directory:
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Quotation extends Model {
protected $table = 'quotation_texts';
}
You attempted to access it via Quotation::find(176), but received Class 'App\Http\Controllers\Quotation' not found. This error suggests that your application is looking for the class inside App\Http\Controllers rather than App.
This usually happens when a global alias or a helper function from an older Laravel version (like L3 or early L4) is still being loaded, forcing the resolver to check controller directories first. In Laravel 5, models are autoloaded directly from their respective namespaces. If your file is named Quotations.php but you define the class as Quotation, PHP will throw a fatal error because the filename must match the class name exactly when placed in the namespace root.
Rename your file to Quotation.php and ensure it sits directly inside app/Models if you are using Laravel 5.1+ (or just app/ for earlier 5.x versions depending on your exact setup). The correct path structure for a class named App\Quotation is simply app/Quotation.php.
Once the file name matches the class definition and the namespace is declared correctly at the top of the file, the autoloader will find it immediately. There is no need to manually register it in a service provider unless you are using a legacy bootstrap method that explicitly maps global aliases.
Verifying the Environment
If these steps do not resolve the issue, inspect your config/autoload.php file (in older Laravel 5 versions) or your bootstrap/app.php. You may have a leftover line defining a custom facade or model alias that points to the wrong directory. Look for any manual class loading logic that forces the loader into App\Http\Controllers. Removing these legacy overrides restores standard behavior.
Finally, verify that your database migrations have run successfully and that the table quotation_texts actually exists. While this doesn't cause the Class not found error directly, it is a common follow-up issue when developers switch namespaces mid-migration. Ensure you are querying against the correct schema name if you are using a multi-tenant setup or a specific connection defined in your config/database.php.
