File: /home/posscale/public_html/printmanager/app/Filament/Resources/SupplierTonerPriceResource.php
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\SupplierTonerPriceResource\Pages;
use App\Filament\Resources\SupplierTonerPriceResource\RelationManagers;
use App\Models\Supplier;
use App\Models\SupplierTonerPrice;
use App\Models\TonerInk;
use Filament\Forms;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
class SupplierTonerPriceResource extends Resource
{
protected static ?string $model = SupplierTonerPrice::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = "Printer Parts";
protected static ?int $navigationSort = 8;
public static function form(Form $form): Form
{
return $form
->schema([
Select::make('toner_inks_id')
->label('Toner Ink ID')
->options(TonerInk::all()->pluck('part_no', 'id'))
->searchable()->required(true),
Select::make('supplier_id')
->label('Supplier ID')
->options(Supplier::all()->pluck('name', 'id'))
->searchable()->required(true),
TextInput::make('supplier_part_no')->label('Supplier Part No')->required(true),
TextInput::make('price')->numeric()->rules(['decimal:0,2']) ->label('Price')->required(true),
TextInput::make('last_freight_cost')->numeric()->rules(['decimal:0,2']) ->label('Last Freight Cost')->required(true),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('tonerlink.part_no'),
TextColumn::make('suppelier.name'),
TextColumn::make('supplier_part_no'),
TextColumn::make('price'),
TextColumn::make('last_freight_cost'),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListSupplierTonerPrices::route('/'),
'create' => Pages\CreateSupplierTonerPrice::route('/create'),
'edit' => Pages\EditSupplierTonerPrice::route('/{record}/edit'),
];
}
}