sunel / eav Goto Github PK
View Code? Open in Web Editor NEWEntity–attribute–value model (EAV) for Laravel Artisan
Home Page: https://sunel.github.io/eav/
Entity–attribute–value model (EAV) for Laravel Artisan
Home Page: https://sunel.github.io/eav/
Hello, @sunel !
I write a controller to handle CRUD attributes. I get errors in the edit
method.
Eav\Attribute::code must return a relationship instance. (View: C:\OSPanel\domains\vpalette\resources\views\admin_product_attributes\fields.blade.php) (View: C:\OSPanel\domains\vpalette\resources\views\admin_product_attributes\fields.blade.php)
Where AttributeModel
it's use Eav\Attribute as AttributeModel;
How to correct made ?
Is there support for laravel 5.4?
I am getting the following problem when installing:
Problem 1
- Installation request for sunel/eav dev-master -> satisfiable by sunel/eav[dev-master].
- Conclusion: remove laravel/framework v5.4.36
- Conclusion: don't install laravel/framework v5.4.36
- sunel/eav dev-master requires illuminate/database 5.5.* -> satisfiable by laravel/framework[5.5.x-dev], illuminate/database[5.5.x-dev, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39].
- don't install laravel/framework 5.5.x-dev|don't install laravel/framework v5.4.36
- don't install illuminate/database 5.5.x-dev|don't install laravel/framework v5.4.36
- don't install illuminate/database v5.5.0|don't install laravel/framework v5.4.36
- don't install illuminate/database v5.5.16|don't install laravel/framework v5.4.36
- don't install illuminate/database v5.5.17|don't install laravel/framework v5.4.36
- don't install illuminate/database v5.5.2|don't install laravel/framework v5.4.36
- don't install illuminate/database v5.5.28|don't install laravel/framework v5.4.36
- don't install illuminate/database v5.5.33|don't install laravel/framework v5.4.36
- don't install illuminate/database v5.5.34|don't install laravel/framework v5.4.36
- don't install illuminate/database v5.5.35|don't install laravel/framework v5.4.36
- don't install illuminate/database v5.5.36|don't install laravel/framework v5.4.36
- don't install illuminate/database v5.5.37|don't install laravel/framework v5.4.36
- don't install illuminate/database v5.5.39|don't install laravel/framework v5.4.36
- Installation request for laravel/framework == 5.4.36.0 -> satisfiable by laravel/framework[v5.4.36].
Please add support
Hello
i have a bigInteger attribute assigned to my entity
when try to insert a new row to DB of that entity
it tries to insert to product_item_biginteger instead of product_item_biginteger
the I should be uppercase
and it result this exception
Illuminate\Database\QueryException : SQLSTATE[42S02]: Base table or view not found: 1146 Table 'iranrentercore.product_item_biginteger' doesn't exist (SQL: insert into `product_item_biginteger` (`entity_type_id`, `attribute_id`, `entity_id`, `value`) values (2, 20, 1, 3460528))
at /home/sinamiandashti/projects/iranrenter/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
Replay: Run migrate then run migrate: refresh
I just followed your documentation. but when I create a product I get this error
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'name' in 'field list' (SQL: insert into
bikes (
name,
sku,
description,
search,
attribute_set_id,
entity_id,
updated_at,
created_at) values (Flight 2, FLG12, This is a bike sample description., 1, 1, 1, 2018-07-25 08:29:29, 2018-07-25 08:29:29))
Obviously, I don't have the name, description and other fields in my bikes table.
In your documentation you said
YOU NEED TO EDIT THE ATTRIBUTES INFO IN THE MIGRATION
Can you please explain this to me.
As laravel binds all the column names into one big identifier name it exceeds mysql limitation of 64 chars.
Eg.
SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'sclera_attribute_groups_attribute_set_id_attribute_group_name_unique' is too long (SQL: alter table `sclera_attribute_groups` add unique `sclera_attribute_groups_attribute_set_id_attribute_group_name_unique`(`attribute_set_id`, `attribute_group_name`))
Proposed solution: Specify a name for each identifier
eg. (create_attribute_groups_table.php)
$table->unique(['attribute_set_id', 'attribute_group_name'], 'set_id-group_name-unique');
Is this project still active ? as the releases still state 'beta'?
Is there a production release on schedule?
Following Code In ReadMe
How to Register this in artisan ? Can You Add It In ReadMe ? Thx !
php artisan eav:make:entity product \App\Products
Have you consider it to make Nova Package, I can contribute!
Docs says:
$product->baseEntity;
But this returns error:
$product->baseEntity();
- works ok but maybe it should return relationship
and
$product->baseEntity()->get()
- should do the job same as $product->baseEntity;
Can you help me create example application with simple product and configuable product like magento ?
Thanks you so much.
Can you explain how to add select and multiselect attribute options
Hi,
Anyone has implement i18n ?
With Spatie package by example.
sunel/json-api-resources lock laravel v6
update illuminate package versions in sunel/json-api-resources to ^6.*
Please
Hi @sunel !
Can you help, I have two models. First AdminProduct
- base model holds info about the product.
The second model - It's Eav model AttributeProducts. Below my source code.
AdminProduct model
AttributeProducts model
And I have pivot table admin_product_attr
Now I want to find the product by id with all attributes attached to a single product.
I can get inverse by AttributeProducts all attributes & product.
Hello, I think in the relation, the primary key of AttributeSet should be added as parameter, because now the relation is not working
public function attributeGroup() { return $this->hasMany(AttributeGroup::class, 'attribute_set_id'); }
I've an entity App\Product
and using the spatie/laravel-sluggable package to create a slug for each product.
The slug is defined as a static attribute and the column slug is available on the products table but when a product is created no slug is inserted.
Even with a basic boot method to listen for events on my Product model this is ignored:
public static function boot()
{
parent::boot();
static::creating(function($data) {
$data->slug = 'test';
});
}
The core snippet from the package is using the magic boot mechanism like so:
HasSlug Trait:
protected static function bootHasSlug()
{
static::creating(function (Model $model) {
$model->generateSlugOnCreate();
});
static::updating(function (Model $model) {
$model->generateSlugOnUpdate();
});
}
Hello @sunel !
How to retrieve all attributes by id model. I want to retrieve only all attributes by id model. Because where I write code like this: $attributes = App\Models\AdminProduct::select(['attr.*']->find(1);
I get all attributes plus I get my static fields.
Thanks in advance for your reply @sunel
What do I need to insert multiple properties for each product, giving me an example of a product with multiple attributes, each with different price attributes. thank you
Hello Sunel,
I am finding the attached error in the extension . https://github.com/sunel/eav/blob/master/docs/master/dashboard.md
laraval version 6
When I run the command 'php artisan eav:compile:entity product' to create the flat table I get the following error:
Compiling product
entity.
Creating flat table for products
.
in C:\Websites\eavproject\database/migrations/eav/products_flat.php
Found 14 attributes.
In products_flat.php line 18:
syntax error, unexpected '(', expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$'
And it creates the products_flat.php with the following syntax errors:
....
....
public function up()
{
Schema::dropIfExists('products_flat');
Schema::create('products_flat', function (Blueprint $table) {
$table->('');
$table->string()('accessible_furniture_shape')->nullable();
$table->string()('item_weight_kg')->nullable();
$table->string()('strength_options')->nullable();
$table->string()('size')->nullable()->default('s');
$table->string()('length')->nullable();
$table->string()('width')->nullable();
$table->string()('item_weight_g')->nullable();
$table->int('featured_product')->nullable();
$table->string()('garden_tool_type')->nullable();
$table->string()('accessible_furniture_material')->nullable();
$table->int('garden_stool_arms')->nullable();
$table->string()('color_options')->nullable();
$table->string()('garden_tools_material')->nullable();
$table->string()('weight')->nullable();
});
}
.....
Any idea why is this happening? Thanks.
@sunel, when we delete a model, say we delete a product, any attributes attached for that product like name, SKU (saved in varchar table) don't get deleted.
It just deletes the Product model, not all the footprints.
I think this fix will help people to keep their database clean. Let me know if this one is possible.
Thanks
In the rollback (down method) the datetime table is written as _dateTime instead of _customers_datetime
I have product entity. I want to load all attributes data by primary key id. Pkg have any method to get this.
Hello,
how can you take a model instance with all its attribute values. For example I have Product with attribute name. If I want to update the value of name I can make:
`$product = Products::find(1);
$product->name = 'Not a Flamethrower';
$product->save();`
but how can I display $product->name
. If i try to dd($product->name)
the result is null
Hi,
I have used your package to complete my project and done almost whole of my project. Just found that when I create a Product Model and it extends your Eav\Model. If I put a belongstoMany relationship with another model which is extending Laravel model it doesn't return anything. I know you have already extended the Eloquent Model and all relationship should be working fine but it's not.
Any idea? If you can guide me on this.
Thanks
I am developing a products listing page, which has a filter sidebar for attributes and tags. The filter is based on checkboxes and users can select multiple filters.
30cm (12 products)
20 cm (3 products)
2 Kg (3 products)
12 Kg (6 products)
Outdoor Seating ( 4 products)
Long Handled Equipment ( 12 counts)
my product model has the following relationship:
public function attributes() {
return $this->hasMany('Eav\Attribute', 'entity_id');
}
public function categories() {
return $this->belongsToMany('App\Category', 'category_product', 'product_id', 'category_id');
}
public function tags() {
return $this->belongsToMany('App\Tag', 'product_tag');
}
I have the following function in my product model, to filter the category products on attributes and tags:
public function scopeFilter($q) {
// filter on EAV attributes
$filter = request('filter');
foreach ($filter as $filter_code => $values) :
$q->whereInAttribute($filter_code, $values);
endforeach;
// filter on tags
$tags = request('tag');
$q->whereHas('tags', function ($query) use ($tags) {
$query->whereIn('slug', $tags);
});
......
return $q;
}
Can you advise me how to develop such a function to get the eloquent query to return selected EAV attributes OR (not AND) selected tags?
Many Thanks.
Hi, there is a way to integrate this project with laravel-translatable? I imagine that may be hard, but its possible? If yes, what need to be done?
When I try the following query using parameter grouping :
`
$type1 = 'cultivator';
$type2 = 'fork';
$products = Product::whereAttribute('garden_tool_material', '=', 'wooden')
->whereAttribute(function ( $query) use ($type1, $type2) {
$query->whereAttribute('garden_tool_type', '=', $type1);
$query->orWhereAttribute('garden_tool_type', '=', $type2);
})->get()
->select(['attr.*']);
`
I get the error:
Illegal offset type
Hi,
Can you please update the package to support Laravel 6. I am getting the below error
Call to undefined function Eav\Traits\array_get()
Array and string helper functions are removed from the Laravel 6.
Can you please make an update to this package.
Thanks
When running the $ php artisan eav:compile:entity [entity_code]
It can not find the schema information as my table-prefix is added to the information_schema table as well.
PDOException::("SQLSTATE[42S02]: Base table or view not found: 1146 Table 'sclera_sclera_information_schema.columns' doesn't exist")
Products::find(1)->all(['attr.*']); is wrong
@sunel we are using your package and we are nearly there with our project. Just found an issue when you assign 60+ attributes to a product or model we are getting the following problem upon saving or updating the product.
SQLSTATE[HY000]: General error: 1116 Too many tables; MySQL can only use 61 tables in a join (SQL: select
bikes.
id,
details_gallery_attr.
valueas
details_gallery,
geometry_gallery_attr.
valueas
geometry_gallery,
hero_gallery_attr.
valueas
hero_gallery,
image_attr.
valueas
image, .............
I think you have to refine the query to save only attributes provided not all the attributes.
Can you please look at this as its urgent.
Thanks
When I run the code:
$statusAttr = Eav\Attribute::with('optionValues')->findByCode('size', 'product');
I get the following error:
BadMethodCallException
Call to undefined method Illuminate\Database\Eloquent\Builder::findByCode()
I have 2 attribute same name of 2 entity.
Get value attr of 2 entity then it show only value of 1 attr.
Other attr is null.
plz fix it
Hi
I have that 2 classes Quotes (Eloquent Model) and Customer (EAV Model)
I created a relationship one to many from Customer to Quote using the hasMany method for the Customer Class and belongsTo for the Quotes Class.
Ho can I get the customer value attributes inside the quote?.
Thanks
Carmine
hello
when i try to compile flat table using this command :
php artisan eav:compile:entity product
Following error happens :
Compiling
product
entity.
Creating flat table forproducts
.
Found 8 attributes.
Migratingproducts
flat schema.Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'created_at' (SQL: create table
products_flat
(id
int unsigned not null,entity_id
int unsigned not null,attribute_set_id
int unsigned not null,slug
varchar(255) not null,order
varchar(255) not null,visit_count
int not null auto_increment primary key,created_at
timestamp null default 'NULL',updated_at
timestamp null default 'NULL',deleted_at
timestamp null default 'NULL',sku
varchar(255) null,name
varchar(255) null,name_en
varchar(255) null,search
varchar(255) null,description
varchar(255) null,status
varchar(255) null,is_active
varchar(255) null,brand
varchar(255) null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')
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 into
products (
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:
`
products
( id
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
Hi,
So far your package is working very well. I just found an issue.
When we have already saved some values for an attribute in my case it's weight set to use the decimal table. But now we want to use the varchar values for this attribute as users want to enter weigh like 50kg or want to attach a note to weight.
I changed the backend table from decimal to varchar and stored the new values.
When we load the value for weight attribute it still refers to the decimal value.
Is it possible to add a check in your package to delete the old value if a table type is changed?
Thanks
Hi @sunel
How to made CRUD operation's use your package.
For example, how to make add new attribute use UI & Laravel Controller's.
Thanks you.
I want color swatch to implement. How can i create color swatch in this PKG
hi
i find issues in your eav extension for laravel ^7.0
for new laravel version you nead fix 2 files in vendor json-api-resources
class Resource extends \Illuminate\Http\Resources\Json\Resource
class Resource extends \Illuminate\Http\Resources\Json\JsonResource
class RelationshipResource extends \Illuminate\Http\Resources\Json\Resource
class RelationshipResource extends \Illuminate\Http\Resources\Json\JsonResource
sanks for your eav
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.