Added weight_validations model and resource page
This commit is contained in:
129
app/Filament/Resources/WeightValidationResource.php
Normal file
129
app/Filament/Resources/WeightValidationResource.php
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
|
use App\Filament\Resources\WeightValidationResource\Pages;
|
||||||
|
use App\Filament\Resources\WeightValidationResource\RelationManagers;
|
||||||
|
use App\Models\WeightValidation;
|
||||||
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
|
|
||||||
|
class WeightValidationResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = WeightValidation::class;
|
||||||
|
|
||||||
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
|
||||||
|
protected static ?string $navigationGroup = 'Weight';
|
||||||
|
|
||||||
|
public static function form(Form $form): Form
|
||||||
|
{
|
||||||
|
return $form
|
||||||
|
->schema([
|
||||||
|
Forms\Components\Select::make('plant_id')
|
||||||
|
->relationship('plant', 'name')
|
||||||
|
->required(),
|
||||||
|
Forms\Components\Select::make('item_id')
|
||||||
|
->relationship('item', 'code')
|
||||||
|
->label('Item Code')
|
||||||
|
->searchable()
|
||||||
|
->required(),
|
||||||
|
Forms\Components\TextInput::make('obd_number')
|
||||||
|
->label('OBD Number')
|
||||||
|
->required(),
|
||||||
|
Forms\Components\TextInput::make('line_number')
|
||||||
|
->label('Line Number')
|
||||||
|
->required(),
|
||||||
|
Forms\Components\TextInput::make('batch_number')
|
||||||
|
->label('Batch Number')
|
||||||
|
->required(),
|
||||||
|
Forms\Components\TextInput::make('heat_number')
|
||||||
|
->label('Heat Number')
|
||||||
|
->required(),
|
||||||
|
Forms\Components\TextInput::make('obd_weight')
|
||||||
|
->label('OBD Weight')
|
||||||
|
->required(),
|
||||||
|
Forms\Components\TextInput::make('vehicle_number')
|
||||||
|
->label('Vehicle Number'),
|
||||||
|
Forms\Components\TextInput::make('bundle_number')
|
||||||
|
->label('Bundle Number'),
|
||||||
|
Forms\Components\TextInput::make('picked_weight')
|
||||||
|
->label('Picked Weight'),
|
||||||
|
Forms\Components\TextInput::make('scanned_by')
|
||||||
|
->label('Scanned By')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
Tables\Columns\TextColumn::make('id')
|
||||||
|
->label('ID')
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('item.id')
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('updated_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('deleted_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
Tables\Filters\TrashedFilter::make(),
|
||||||
|
])
|
||||||
|
->actions([
|
||||||
|
Tables\Actions\ViewAction::make(),
|
||||||
|
Tables\Actions\EditAction::make(),
|
||||||
|
])
|
||||||
|
->bulkActions([
|
||||||
|
Tables\Actions\BulkActionGroup::make([
|
||||||
|
Tables\Actions\DeleteBulkAction::make(),
|
||||||
|
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||||
|
Tables\Actions\RestoreBulkAction::make(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => Pages\ListWeightValidations::route('/'),
|
||||||
|
'create' => Pages\CreateWeightValidation::route('/create'),
|
||||||
|
'view' => Pages\ViewWeightValidation::route('/{record}'),
|
||||||
|
'edit' => Pages\EditWeightValidation::route('/{record}/edit'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getEloquentQuery(): Builder
|
||||||
|
{
|
||||||
|
return parent::getEloquentQuery()
|
||||||
|
->withoutGlobalScopes([
|
||||||
|
SoftDeletingScope::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
36
app/Models/WeightValidation.php
Normal file
36
app/Models/WeightValidation.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class WeightValidation extends Model
|
||||||
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'plant_id',
|
||||||
|
'item_id',
|
||||||
|
'obd_number',
|
||||||
|
'line_number',
|
||||||
|
'batch_number',
|
||||||
|
'heat_number',
|
||||||
|
'obd_weight',
|
||||||
|
'vehicle_number',
|
||||||
|
'bundle_number',
|
||||||
|
'picked_weight',
|
||||||
|
'scanned_by',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function plant(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Plant::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function item(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Item::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user