当我尝试使用 Laravel 5 将数据保存到 mysql 时出现此错误,其他表单和 save() 方法工作正常,但这个:
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 存储方法:
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 而不是 cotizacions。
我该如何解决这个问题?
最佳答案
我猜 Laravel 无法确定您用于表名的单词的复数形式。
只需在模型中指定您的表:
class Cotizacion extends Model{
public $table = "cotizacion";
关于php - 找不到基表或 View : 1146 Table Laravel 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30159257/