Base Table or View Not Found: 1146 Table Laravel 5
When trying to save data to MySQL using Laravel 5, users may encounter the following error:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'sistemal5.cotizacions' doesn't exist
This error typically occurs when Laravel is appending an "S" to the table name, resulting in an invalid table reference.
To troubleshoot this issue, verify the following:
Controller Store Method:
public function store(CotFormRequest $request) { $quote = new Cotizacion; $quote->customer_id = Input::get('data.clientid'); $quote->total = Input::get('data.totalAftertax'); $quote->save(); }
Model:
<?php namespace App\Models\Cotizacion; use Illuminate\Database\Eloquent\Model; class Cotizacion extends Model { }
Potential Issues:
class Cotizacion extends Model{ public $table = "cotizacion"; }
Solution:
To fix this issue, ensure that the table name in the model matches the actual table name in your database and that the plural form is explicitly specified if necessary.
The above is the detailed content of Why Am I Getting a \'Base Table or View Not Found\' Error in Laravel 5?. For more information, please follow other related articles on the PHP Chinese website!