Base table or view not found: 1146 Table Laravel 5

Base table or view not found: 1146 Table Laravel 5

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Base table or view not found: 1146 Table Laravel 5

You are encountering a classic mismatch between your database schema and how Laravel constructs query names. The error SQLSTATE[42S02]: Base table or view not found: 1146 explicitly tells you the engine cannot find the table cotizacions. However, your suspicion is correct: your model is named Cotizacion, and in a standard MySQL setup with default Laravel migrations, the expected table name would be cotizaciones (with an 's' at the end for pluralization).

The discrepancy you are seeing—where Laravel seems to be adding an "S" but you claim the table is cotizacion without one—points to a fundamental naming convention conflict. The root cause lies in how Eloquent maps your PHP classes to database tables. By default, Eloquent uses a singular/plural heuristic to determine table names. It assumes that if your model class is named Cotizacion, the corresponding database table should be its pluralized form: cotizaciones.

If your actual database table is indeed named cotizacion (singular), without the trailing 's', the default behavior breaks. When you execute $quote->save(), Laravel attempts to generate an SQL query against cotizaciones. Since that table does not exist in your schema, MySQL returns the "Base table or view not found" error. The confusion often arises because developers expect Eloquent to automatically handle singular names, but it strictly follows the pluralization rule unless told otherwise.

To resolve this without altering your database schema, you must explicitly tell Eloquent how to map your model to the specific table name. This is handled via the $table property within your model class. By defining this property, you override the default inflection rules.

Update your App\Models\Cotizacion\Cotizacion model as follows:

<?php namespace App\Models\Cotizacion;

use Illuminate\Database\Eloquent\Model;

class Cotizacion extends Model {
    protected $table = 'cotizacion';
}

By setting protected $table = 'cotizacion';, you instruct the ORM to ignore the pluralization heuristic and target the exact string provided. This is the standard, supported way to handle non-standard naming conventions in Laravel 5.

However, there is a critical consideration regarding your controller logic. You are currently using static Input::get() calls to populate attributes manually:

$quote->customer_id = Input::get('data.clientid');
$quote->total = Input::get('data.totalAftertax');    

This approach, while functional for simple assignments, bypasses Laravel's built-in mass assignment protection and event hooks. If you plan to scale this application or utilize features like timestamps automatically (though you are setting them manually in the INSERT statement shown), it is best practice to rely on the request object directly.

In Laravel 5, CotFormRequest extends FormRequest. You should pass the validated input from the request instance into your controller method rather than using static helpers. This ensures that only the fields you intend to save are actually persisted, preventing accidental overwrites of sensitive data like timestamps or deleted_at flags.

public function store(CotFormRequest $request)
{    
    // Create a new instance of the model
    $quote = new Cotizacion;
    
    // Assign validated attributes directly from the request
    $quote->customer_id = $request->input('data.clientid');
    $quote->total = $request->input('data.totalAftertax');
    
    // Save the record
    $quote->save();    
}

Using $request->input() is slightly more performant than Input::get() as it avoids static method resolution overhead, though the difference is negligible for simple assignments. The real benefit here is consistency and type safety. If you later decide to use mass assignment (e.g., $quote->fill($request->all())->save()), you must define $fillable in your model:

protected $fillable = ['customer_id', 'total'];

Without this property, Laravel will reject the mass assignment attempt regardless of how you pass the data. Always audit your fillable attributes to ensure they align with your business logic and security requirements.

By adjusting the model's table property and refactoring the controller to use the request instance, you align your application's internal state with the actual database structure. This eliminates the 1146 error and establishes a more robust foundation for future development.

Our network