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 // Increment and return the row number
return ++$rowNumber; return ++$rowNumber;
}), }),
ExportColumn::make('category')
->label('CATEGORY'),
ExportColumn::make('code') ExportColumn::make('code')
->label('CODE'), ->label('CODE'),
ExportColumn::make('description') ExportColumn::make('description')

View File

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

View File

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

View File

@@ -12,6 +12,7 @@ class Item extends Model
protected $fillable = [ protected $fillable = [
"plant_id", "plant_id",
'category',
'code', 'code',
'description', 'description',
'hourly_quantity', '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) {
// //
// });
}
};