laravel表单数据未保存到数据库

时间:2015-09-08 08:05:44

标签: php database laravel-5 eloquent

laravel给了我一个奇怪的错误,不久前,数据被发送到数据库,现在不是。当我在控制器中执行dd(Input:all())时,我会从表单中获取所有提交的值,这是它的快照。 enter image description here

这是我的功能,我试图将数据插入数据库

$product = new Products;

$product->user_id           = Auth::user()->id;
$product->category_id       = $idOfCategory;
$product->subcategory_id    = $idOfSubCategory;
$product->title             = Input::get('title');
$product->product_slug      = str_slug(Input::get('title'));
$product->description       = Input::get('description');
$product->runtime           = Input::get('runtime');
$product->adtype            = Input::get('adtype');
$product->location          = Input::get('location');
$product->price             = Input::get('price');
$product->image1            = $fileName1;
$product->image2            = $fileName2;
$product->image3            = $fileName3;
$product->negotiable        = Input::get('negotiable');
$product->product_condition = Input::get('product_condition');
$product->usedfor           = Input::get('usedfor');
$product->detailurl         = Input::get('detailurl');
$product->status            = 'available';

$product->save();

这是我的产品型号

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Products extends Model
{
    protected $table = 'products';

}

可能是什么问题?

0 个答案:

没有答案