Giter Site home page Giter Site logo

eav's People

Contributors

craigharley avatar sarav-s avatar sinamiandashti avatar sunel avatar zambodaniel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eav's Issues

Update Method in Controllers

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)

image

Where AttributeModel it's use Eav\Attribute as AttributeModel;

How to correct made ?

Laravel 5.4 support?

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].

bigInteger Table name problem

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|

Can not add a product

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.

Mysql identifier names too long

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

Project still active?

Is this project still active ? as the releases still state 'beta'?
Is there a production release on schedule?

How to add artisan?

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

Example application

Can you help me create example application with simple product and configuable product like magento ?
Thanks you so much.

i18n

Hi,

Anyone has implement i18n ?

With Spatie package by example.

Support Laravel v6

sunel/json-api-resources lock laravel v6
update illuminate package versions in sunel/json-api-resources to ^6.*
Please

Get value attributes by BelongsToMany

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

image

AttributeProducts model

image

And I have pivot table admin_product_attr
image

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.

Relation AttributeSet to AttributeGroup not working

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

Model Event ignored

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

How to retrieve all attributes by id model

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

Cannot run command to create flat table

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.

Attributes data don't get deleted when we delete a Model

@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

Migrate file entity table

In the rollback (down method) the datetime table is written as _dateTime instead of _customers_datetime

How to retrieve one model with all attribute values.

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

Relationship belongsToMany doesnt work.

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

How to develop a products filter with multiple attributes and tags

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.

Filter by Width:

30cm (12 products)
20 cm (3 products)

Filter by Weight:

2 Kg (3 products)
12 Kg (6 products)

Filter by Tags:

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.

Integration with laravel-translatable

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?

error when using parameter grouping in query

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

Laravel 6 Support

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

Flat command table names issue

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

Laravel 7 suport

Hi!
This project will support Laravel 7? I tried install today but show me those messages.

Captura de tela de 2020-03-29 18-11-04

Too many tables; MySQL can only use 61 tables in a join

@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.valueasdetails_gallery, geometry_gallery_attr.valueasgeometry_gallery, hero_gallery_attr.valueashero_gallery, image_attr.valueasimage, .............

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

Error while getting the attribute options values

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

How get value attributes by BelongsTo

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

Invalid default value for 'created_at'

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 for products.
Found 8 attributes.
Migrating products 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')

Insert Error When I Running Example Products

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:
`

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

Deleting old values when we change the attribute backend type from decimal to varchar

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

CRUD operation for EAV

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.

dashboard not work

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

  • in file src\Http\Resources\Json\Resource.php update extends from Resource on JsonResource
class Resource extends \Illuminate\Http\Resources\Json\Resource
class Resource extends \Illuminate\Http\Resources\Json\JsonResource
  • file src\Http\Resources\Json\RelationshipResource.php
class RelationshipResource extends \Illuminate\Http\Resources\Json\Resource
class RelationshipResource extends \Illuminate\Http\Resources\Json\JsonResource

sanks for your eav

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.