ranjith-dev #642
66
app/Filament/Exports/AsrsItemValidationExporter.php
Normal file
66
app/Filament/Exports/AsrsItemValidationExporter.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\AsrsItemValidation;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class AsrsItemValidationExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = AsrsItemValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('item_code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('item_description')
|
||||
->label('ITEM DESCRIPTION'),
|
||||
ExportColumn::make('uom')
|
||||
->label('UOM'),
|
||||
ExportColumn::make('mhe')
|
||||
->label('MHE'),
|
||||
ExportColumn::make('bin_quantity')
|
||||
->label('BIN QUANTITY'),
|
||||
ExportColumn::make('asrs')
|
||||
->label('ASRS'),
|
||||
ExportColumn::make('asrs_category')
|
||||
->label('ASRS CATEGORY'),
|
||||
ExportColumn::make('status')
|
||||
->label('STATUS'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your asrs item validation export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
106
app/Filament/Imports/AsrsItemValidationImporter.php
Normal file
106
app/Filament/Imports/AsrsItemValidationImporter.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\AsrsItemValidation;
|
||||
use App\Models\Plant;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
|
||||
class AsrsItemValidationImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = AsrsItemValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PLANT CODE')
|
||||
->example('1000')
|
||||
->label('PLANT CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item_code')
|
||||
->exampleHeader('ITEM CODE')
|
||||
->example('ITEM001')
|
||||
->label('ITEM CODE')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item_description')
|
||||
->exampleHeader('ITEM DESCRIPTION')
|
||||
->example('Item Description')
|
||||
->label('ITEM DESCRIPTION'),
|
||||
ImportColumn::make('uom')
|
||||
->exampleHeader('UOM')
|
||||
->example('EA')
|
||||
->label('UOM'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?AsrsItemValidation
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = trim($this->data['plant']) ?? '';
|
||||
$iCode = trim($this->data['item_code']) ?? '';
|
||||
$itemDes = trim($this->data['item_description']) ?? '';
|
||||
$uom = trim($this->data['uom']) ?? '';
|
||||
$createdBy = Filament::auth()->user()?->name ?? '';
|
||||
$updatedBy = $createdBy;
|
||||
|
||||
$plantId = null;
|
||||
|
||||
if ($plantCod == null || $plantCod == '' || ! $plantCod) {
|
||||
$warnMsg[] = "Plant code can't be empty!";
|
||||
} elseif (! is_numeric($plantCod)) {
|
||||
$warnMsg[] = "Plant code '{$plantCod}' should contain only numeric values!";
|
||||
} elseif (Str::length($plantCod) < 4 || Str::length($plantCod) > 7) {
|
||||
$warnMsg[] = "Plant code '{$plantCod}' must be between 4 and 7 digits only!";
|
||||
} elseif (! preg_match('/^[1-9]\d{3,6}$/', $plantCod)) {
|
||||
$warnMsg[] = "Invalid plant code '{$plantCod}' found!";
|
||||
} else {
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found!';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
}
|
||||
}
|
||||
if (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
|
||||
$warnMsg[] = 'Invalid item code found';
|
||||
}
|
||||
if (Str::length($itemDes) < 5) {
|
||||
$warnMsg[] = 'Invalid description found';
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
return AsrsItemValidation::updateOrCreate([
|
||||
'item_code' => $iCode,
|
||||
'plant_id' => $plant->id,
|
||||
],
|
||||
[
|
||||
'item_description' => $itemDes,
|
||||
'uom' => trim($this->data['uom']),
|
||||
'created_by' => $createdBy,
|
||||
'updated_by' => $updatedBy,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your asrs item validation import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
231
app/Filament/Resources/AsrsItemValidationResource.php
Normal file
231
app/Filament/Resources/AsrsItemValidationResource.php
Normal file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\AsrsItemValidationExporter;
|
||||
use App\Filament\Imports\AsrsItemValidationImporter;
|
||||
use App\Filament\Resources\AsrsItemValidationResource\Pages;
|
||||
use App\Filament\Resources\AsrsItemValidationResource\RelationManagers;
|
||||
use App\Models\AsrsItemValidation;
|
||||
use Filament\Facades\Filament;
|
||||
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;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Forms\Get;
|
||||
use App\Models\Item;
|
||||
|
||||
class AsrsItemValidationResource extends Resource
|
||||
{
|
||||
protected static ?string $model = AsrsItemValidation::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->required()
|
||||
->disabledOn('edit'),
|
||||
Forms\Components\Select::make('item_code')
|
||||
->label('Item Code')
|
||||
->reactive()
|
||||
->options(function (Get $get) {
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
if (!$plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return AsrsItemValidation::where('plant_id', $plantId)
|
||||
->pluck('item_code', 'item_code');
|
||||
})
|
||||
->searchable()
|
||||
->afterStateUpdated(function (callable $set, $state) {
|
||||
$item = AsrsItemValidation::where('item_code', $state)->first();
|
||||
|
||||
if ($item) {
|
||||
$set('item_description', $item->item_description);
|
||||
$set('uom', $item->uom);
|
||||
} else {
|
||||
$set('item_description', null);
|
||||
$set('uom', null);
|
||||
}
|
||||
})
|
||||
->disabledOn('edit'),
|
||||
Forms\Components\TextInput::make('item_description')
|
||||
->label('Item Description')
|
||||
->readOnly()
|
||||
->reactive()
|
||||
->disabledOn('edit'),
|
||||
Forms\Components\TextInput::make('uom')
|
||||
->label('UOM')
|
||||
->readOnly()
|
||||
->reactive()
|
||||
->disabledOn('edit'),
|
||||
Forms\Components\Select::make('mhe')
|
||||
->label('MHE')
|
||||
->options([
|
||||
'Bin1000*800*750' => 'Bin 1000*800*750',
|
||||
'Bin1000*800*1000' => 'Bin 1000*800*1000',
|
||||
'Pallet' => 'Pallet',
|
||||
'ChinaBin' => 'China Bin',
|
||||
'PalletWithPlasticCrate' => 'Pallet With Plastic Crate',
|
||||
'PlasticCrateBig' => 'Plastic Crate Big',
|
||||
'PlasticCrateSmall' => 'Plastic Crate Small',
|
||||
'OutsideStorage' => 'Outside Storage',
|
||||
]),
|
||||
Forms\Components\TextInput::make('bin_quantity')
|
||||
->label('Bin Quantity'),
|
||||
Forms\Components\Select::make('asrs')
|
||||
->label('ASRS')
|
||||
->options([
|
||||
'ASRS1' => 'ASRS1',
|
||||
'ASRS2' => 'ASRS2',
|
||||
]),
|
||||
Forms\Components\Select::make('asrs_category')
|
||||
->label('ASRS Category')
|
||||
->options([
|
||||
'In' => 'In',
|
||||
'Out' => 'Out',
|
||||
]),
|
||||
Forms\Components\Select::make('status')
|
||||
->label('Status')
|
||||
->options([
|
||||
'Updated' => 'Updated',
|
||||
'NotUpdated' => 'Not Updated',
|
||||
]),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name ?? ''),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By')
|
||||
->default(Filament::auth()->user()?->name ?? ''),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
})
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item_code')
|
||||
->label('Item Code')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item_description')
|
||||
->label('Item Description')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('uom')
|
||||
->label('UOM')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('mhe')
|
||||
->label('MHE')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('bin_quantity')
|
||||
->label('Bin Quantity')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('asrs')
|
||||
->label('ASRS')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('asrs_category')
|
||||
->label('ASRS Category')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->label('Status')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
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(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(AsrsItemValidationImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import asrs item validation');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(AsrsItemValidationExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export asrs item validation');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListAsrsItemValidations::route('/'),
|
||||
'create' => Pages\CreateAsrsItemValidation::route('/create'),
|
||||
'view' => Pages\ViewAsrsItemValidation::route('/{record}'),
|
||||
'edit' => Pages\EditAsrsItemValidation::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\AsrsItemValidationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\AsrsItemValidationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateAsrsItemValidation extends CreateRecord
|
||||
{
|
||||
protected static string $resource = AsrsItemValidationResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\AsrsItemValidationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\AsrsItemValidationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditAsrsItemValidation extends EditRecord
|
||||
{
|
||||
protected static string $resource = AsrsItemValidationResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\AsrsItemValidationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\AsrsItemValidationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListAsrsItemValidations extends ListRecords
|
||||
{
|
||||
protected static string $resource = AsrsItemValidationResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\AsrsItemValidationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\AsrsItemValidationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewAsrsItemValidation extends ViewRecord
|
||||
{
|
||||
protected static string $resource = AsrsItemValidationResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Models/AsrsItemValidation.php
Normal file
33
app/Models/AsrsItemValidation.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class AsrsItemValidation extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'item_code',
|
||||
'item_description',
|
||||
'uom',
|
||||
'mhe',
|
||||
'bin_quantity',
|
||||
'asrs',
|
||||
'asrs_category',
|
||||
'status',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
}
|
||||
106
app/Policies/AsrsItemValidationPolicy.php
Normal file
106
app/Policies/AsrsItemValidationPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\AsrsItemValidation;
|
||||
use App\Models\User;
|
||||
|
||||
class AsrsItemValidationPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any AsrsItemValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, AsrsItemValidation $asrsitemvalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view AsrsItemValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create AsrsItemValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, AsrsItemValidation $asrsitemvalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update AsrsItemValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, AsrsItemValidation $asrsitemvalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete AsrsItemValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any AsrsItemValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, AsrsItemValidation $asrsitemvalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore AsrsItemValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any AsrsItemValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, AsrsItemValidation $asrsitemvalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate AsrsItemValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder AsrsItemValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, AsrsItemValidation $asrsitemvalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete AsrsItemValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any AsrsItemValidation');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?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
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE asrs_item_validations (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
|
||||
plant_id BIGINT NOT NULL,
|
||||
item_code TEXT DEFAULT NULL,
|
||||
item_description TEXT DEFAULT NULL,
|
||||
uom TEXT DEFAULT NULL,
|
||||
mhe TEXT DEFAULT NULL,
|
||||
bin_quantity TEXT DEFAULT NULL,
|
||||
asrs TEXT DEFAULT NULL,
|
||||
asrs_category TEXT DEFAULT NULL,
|
||||
status TEXT DEFAULT NULL,
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
created_by TEXT DEFAULT NULL,
|
||||
updated_by TEXT DEFAULT NULL,
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
FOREIGN KEY (plant_id) REFERENCES plants (id)
|
||||
);
|
||||
SQL;
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('asrs_item_validations');
|
||||
}
|
||||
};
|
||||
@@ -225,5 +225,9 @@ class PermissionSeeder extends Seeder
|
||||
Permission::updateOrCreate(['name' => 'view print production order button']);
|
||||
Permission::updateOrCreate(['name' => 'view save production order button']);
|
||||
Permission::updateOrCreate(['name' => 'view print panel production order button']);
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view import asrs item validation']);
|
||||
Permission::updateOrCreate(['name' => 'view export asrs item validation']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user