Added category column for items masters

This commit is contained in:
dhanabalan
2025-06-03 16:35:02 +05:30
parent 7760c64ed3
commit 29c092a860
5 changed files with 52 additions and 1 deletions

View File

@@ -24,6 +24,8 @@ class ItemExporter extends Exporter
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('category')
->label('CATEGORY'),
ExportColumn::make('code')
->label('CODE'),
ExportColumn::make('description')

View File

@@ -17,6 +17,11 @@ class ItemImporter extends Importer
public static function getColumns(): array
{
return [
ImportColumn::make('category')
->requiredMapping()
->exampleHeader('Category')
->example('Submersible Motor')
->label('Category'),
ImportColumn::make('code')
->requiredMapping()
->exampleHeader('Item Code')
@@ -78,6 +83,7 @@ class ItemImporter extends Importer
'plant_id' => $plant->id
],
[
'category' => $this->data['category'],
'description' => $this->data['description'],
'hourly_quantity' => $this->data['hourly_quantity'],
'uom' => $this->data['uom']

View File

@@ -66,6 +66,10 @@ class ItemResource extends Resource
])
->hint(fn ($get) => $get('iPlantError') ? $get('iPlantError') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('category')
->label('Category')
->placeholder('Scan the Category'),
Forms\Components\TextInput::make('code')
->required()
->placeholder('Scan the valid code')
@@ -146,7 +150,7 @@ class ItemResource extends Resource
->placeholder('Scan the valid description')
->required()
->minLength(5)
->columnSpan(['default' => 1, 'sm' => 2]),
->columnSpan(['default' => 1, 'sm' => 1]),
// ->columnSpanFull(),
Forms\Components\TextInput::make('id')
->hidden()
@@ -178,6 +182,11 @@ class ItemResource extends Resource
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('category')
->label('Category')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('description')
->label('Description')
->alignCenter()

View File

@@ -12,6 +12,7 @@ class Item extends Model
protected $fillable = [
"plant_id",
'category',
'code',
'description',
'hourly_quantity',

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$sql1 = <<<'SQL'
ALTER TABLE items
ADD category TEXT DEFAULT NULL;
SQL;
DB::statement($sql1);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Schema::table('item_masters', function (Blueprint $table) {
// //
// });
}
};