sunel / eav

Entity–attribute–value model (EAV) for Laravel Artisan
https://sunel.github.io/eav/
143 stars 39 forks source link

Insert Error When I Running Example Products #5

Closed liuminggrowing closed 6 years ago

liuminggrowing commented 6 years ago

When I Running Example : `<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Products;

class test extends Controller { // public function createProductes() { Products::create([ 'name' => 'Flamethrower', 'sku' => '1HJK92', 'upc' => 'SHNDUU451888', 'description' => 'Not a Flamethrower', 'search' => 1, ]); echo "done"; } }`

Get This Error: Illuminate \ Database \ QueryException (42S22) SQLSTATE[42S22]: Column not found: 1054 Unknown column 'name' in 'field list' (SQL: insert intoproducts(name,sku,description,search,attribute_set_id,entity_id,updated_at,created_at) values (Flamethrower, 1HJK92, Not a Flamethrower, 1, 1, 1, 2018-05-17 03:03:28, 2018-05-17 03:03:28))

And The products table: `

CREATE TABLE productsid int(10) unsigned NOT NULL AUTO_INCREMENT, entity_id int(10) unsigned NOT NULL, attribute_set_id int(10) unsigned NOT NULL, created_at timestamp NULL DEFAULT NULL, updated_at timestamp NULL DEFAULT NULL, PRIMARY KEY (id)) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

`

I just Following the ReadMe , Maybe I just got something wrong , help T T

liuminggrowing commented 6 years ago

Case About Products Cant Use, But Attribute is Ok

sunel commented 6 years ago

Can you post the Product Model.

sunel commented 6 years ago

I think the problem is with the attributes added

Have you updated the backend_type, frontend_type

refer this https://github.com/sunel/eav#add-attribute

i am trying to improve the doc, eav is a bit difficult concept so writing down the whole thing is little bit difficult.

liuminggrowing commented 6 years ago

Yes ! I Just Found Why, It Just Like You said, backend_type is empty when use migrate to initialized. I change it to varchar , and the case is ok ! 3Q for your answer, may be my mysql need to be updated ^_^

sunel commented 6 years ago

I have added the note in the read me, thanks for pointing that out.