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:
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.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3