Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Base table or view not found: 1146 Table Laravel 5

Tags:

php

mysql

laravel

Im getting this error when I try to save data to mysql using Laravel 5, other forms and save() methods work fine but this one:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'sistemal5.cotizacions' doesn't exist (SQL: insert into `cotizacions` (`customer_id`, `total`, `updated_at`, `created_at`) values (1501, 150.69, 2015-05-11 03:16:25, 2015-05-11 03:16:25)) 

Here is my 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();         } 

And here is my model:

<?php namespace App\Models\Cotizacion;  use Illuminate\Database\Eloquent\Model;   class Cotizacion extends Model {  } 

I must be overlooking something really obvious cause i cant understand why Laravel is adding an "S" the table is cotizacion not cotizacions.

How can i troubleshoot this?

like image 751
ray sn0w Avatar asked May 11 '15 03:05

ray sn0w


1 Answers

I'm guessing Laravel can't determine the plural form of the word you used for your table name.

Just specify your table in the model as such:

class Cotizacion extends Model{     public $table = "cotizacion"; 
like image 184
James Spence Avatar answered Sep 28 '22 14:09

James Spence