Skip to content

Commit

Permalink
Changes to files: Entities/Category.php
Browse files Browse the repository at this point in the history
Entities/Product.php
  • Loading branch information
dedanirungu committed Apr 25, 2024
1 parent 6318a48 commit 7223310
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
5 changes: 3 additions & 2 deletions Entities/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ class Category extends BaseModel
public function fields(Blueprint $table = null): void
{
$this->fields = $table ?? new Blueprint($this->table);

$this->fields->increments('id')->html('hidden');
$this->fields->string('name')->nullable()->html('text');
$this->fields->integer('parent')->default(0)->html('text');
$this->fields->foreignId('parent')->nullable()->html('recordpicker')->relation(['product', 'category']);

}

/**
Expand Down
22 changes: 15 additions & 7 deletions Entities/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Product extends BaseModel
*
* @var array<string>
*/
protected $fillable = ['name', 'product_type_id', 'category_id', 'tax_cat_id', 'vendor', 'cost_price', 'sale_price'];
protected $fillable = ['name', 'type_id', 'category_id', 'vendor', 'cost_price', 'sale_price', 'size', 'color', 'discount', 'width', 'height', 'weight', 'shipping_cost', 'sku', 'tags', 'description', 'image', 'gallery'];

/**
* The fields that are to be render when performing relationship queries.
Expand Down Expand Up @@ -49,8 +49,11 @@ public function fields(Blueprint $table = null): void
$this->fields->increments('id')->html('hidden');
$this->fields->string('name')->nullable()->html('text');
$this->fields->integer('description')->nullable()->html('editor');
$this->fields->integer('category_id')->nullable()->html('recordselect');
$this->fields->integer('sub_category_id')->nullable()->html('recordselect');
$this->fields->integer('category_id')->nullable()->html('recordselect')->relation(['product', 'category']);
$this->fields->integer('type_id')->nullable()->html('recordselect')->relation(['product', 'type']);
$this->fields->integer('vendor')->nullable()->html('recordselect')->relation(['product', 'vendor']);
$this->fields->integer('image')->nullable()->html('image');
$this->fields->integer('gallery')->nullable()->html('gallery');
$this->fields->integer('tags')->nullable()->html('tags');
$this->fields->integer('sku')->nullable()->html('text');
$this->fields->integer('discount')->nullable()->html('records');
Expand All @@ -62,6 +65,7 @@ public function fields(Blueprint $table = null): void
$this->fields->decimal('shipping_cost', 20, 2)->default(0.00)->html('amount');
$this->fields->decimal('cost_price', 20, 2)->default(0.00)->html('amount');
$this->fields->decimal('sale_price', 20, 2)->default(0.00)->html('amount');

}

/**
Expand All @@ -70,22 +74,26 @@ public function fields(Blueprint $table = null): void
public function structure($structure): array
{

$structure['table'] = ['name', 'description', 'category_id', 'tax_cat_id', 'vendor', 'cost_price', 'sale_price'];
$structure['table'] = ['name', 'sku', 'category_id', 'vendor', 'cost_price', 'sale_price', 'shipping_cost', 'size', 'color', 'discount', 'width', 'height', 'weight'];

$structure['form'] = [
['label' => 'Product Name', 'class' => 'col-span-full', 'fields' => ['name']],
['label' => 'Product Detail', 'class' => 'col-span-full md:col-span-6ull md:col-span-6ull md:col-span-6 md:pr-2', 'fields' => ['product_type_id', 'category_id', 'tax_cat_id']],
['label' => 'Product Detail', 'class' => 'col-span-full md:col-span-6ull md:col-span-6ull md:col-span-6 md:pr-2', 'fields' => ['type_id', 'category_id']],
['label' => 'Other Product Setting ', 'class' => 'col-span-full md:col-span-6ull md:col-span-6 md:pr-2', 'fields' => ['vendor', 'cost_price', 'sale_price']],
['label' => 'Product Name', 'class' => 'col-span-full', 'fields' => ['image', 'gallery']],
['label' => 'Product Name', 'class' => 'col-span-full', 'fields' => ['tags', 'sku']],
['label' => 'Product Name', 'class' => 'col-span-full', 'fields' => ['description']],
['label' => 'Product Name', 'class' => 'col-span-full', 'fields' => ['width', 'height', 'weight', 'shipping_cost']],
['label' => '', 'class' => 'col-span-full', 'tabs' => [
['label' => 'Size', 'class' => 'col-span-full', 'fields' => ['size']],
['label' => 'Color', 'class' => 'col-span-full', 'fields' => ['color']],
]],
]],
['label' => '', 'class' => 'col-span-full', 'tabs' => [
['label' => 'Discount', 'class' => 'col-span-full', 'fields' => ['discount']],
]],
];

$structure['filter'] = ['name', 'product_type_id', 'category_id', 'tax_cat_id'];
$structure['filter'] = ['name', 'type_id', 'category_id', 'vendor', 'cost_price', 'sale_price'];

return $structure;
}
Expand Down

0 comments on commit 7223310

Please sign in to comment.