找不到基本表或视图:1146表Laravel 5 [英] Base table or view not found: 1146 Table Laravel 5

查看:78
本文介绍了找不到基本表或视图:1146表Laravel 5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用Laravel 5将数据保存到mysql时,出现了此错误,其他形式和save()方法都可以正常工作,但这是这样的:

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))

这是我的Controller存储方法:

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

这是我的模特:

<?php namespace App\Models\Cotizacion;

use Illuminate\Database\Eloquent\Model;


class Cotizacion extends Model {

}

我必须忽略一些确实很明显的事情,因为我不明白为什么Laravel在表上添加了"S",这是在保留cotizacion,而不是保留cotizacion.

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

如何解决此问题?

推荐答案

我猜想Laravel无法确定用于表名的单词的复数形式.

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";

这篇关于找不到基本表或视图:1146表Laravel 5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆