laraplug / attribute-module
Installs: 201
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Type:asgard-module
Requires
- php: >=7.0.0
- composer/installers: ~1.0
- idavoll/core-module: ~3.0
Requires (Dev)
- orchestra/testbench: 3.5.*
- phpunit/phpunit: ~6.0
This package is not auto-updated.
Last update: 2024-11-10 06:12:25 UTC
README
Laraplug Attribute
Laraplug Attribute is a EAV e-commerce module, built on top of AsgardCMS platform.
Successfully implemented on laraplug/product-module
Table Of Contents
Installation
-
Install the package via composer:
composer require laraplug/attribute-module
-
Execute migrations via AsgardCMS's module command:
php artisan module:migrate Attribute
-
Execute publish via AsgardCMS's module command:
php artisan module:publish Attribute
-
Done!
Usage
Add EAV to Eloquent model
To add EAV functionality to your Eloquent model, just use the \Module\Attribute\Traits\Attributable
trait and implement \Module\Attribute\Contracts\AttributesInterface
like this:
use \Module\Attribute\Contracts\AttributesInterface use \Module\Attribute\Traits\Attributable class Book extends Model implements AttributesInterface { use Attributable; }
Configure attributes on Eloquent model
Add $systemAttributes
on your entity to add attributes on code-level:
use \Module\Attribute\Contracts\AttributesInterface use \Module\Attribute\Traits\Attributable class Book extends Model implements AttributesInterface { use Attributable; ... // Set systemAttributes to define EAV attributes protected $systemAttributes = [ 'isbn' => [ 'type' => 'input' ], 'media' => [ 'type' => 'checkbox', 'options' => [ 'audio-cd', 'audio-book', 'e-book', ] ] ]; }
Available SystemAttributes Parameters
type : String of input type (list below)
input
: input[type=text]textarea
: teaxarearadio
: input[type=radio]checkbox
: input[type=checkbox]select
: selectmultiselect
: select[multiple]
options : Array of option keys
has_translatable_values : boolean
About Laraplug
LaraPlug is a opensource e-commerce project built on top of AsgardCMS.
Contributing
We welcome any pull-requests or issues :)