I'm developing a shopping cart system using October cms platform. Some product items will have multiple colours.
But using default colorpicker, I don't know how to select multiple colors. I searched all over the internet but I didn't get an answer for my situation. Any help would be much appreciated.
Hmm may be just use repeater and add colour picker inside it so you can add N no. of colour
[this is easy way but if you are using this attribute/values in search then this is not preferred way use mm relation
for it then]
it will be stored as json
in database field you can add this to model
namespace HardikSatasiya\Plugin\Models;
use Model;
class Product extends Model
{
protected $jsonable = ['product_colors'];
....
schema
Schema::create('hardiksatasiya_pluginname_products', function($table)
{
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('name')->nullable();
$table->string('slug')->index();
$table->text('product_colors')
You can define repeater like this.
product_colors:
type: repeater
form:
fields:
color:
label: Background
type: colorpicker
As $model->product_colors will be having array of
colors
like his
$model->product_colors <=> [ 0 => [ 'color' => 'red'], 1 => [ 'color' => 'blue'] ]
to access values you can directly use $model->product_colors it will be
array so you can loop through it
.
// $model->product_colors[0]->color -> red
// $model->product_colors[1]->color -> blue
if any doubts please comment.