Files
pos_heidiver/app/Filament/Resources/ProveedorResource.php
T
Juan Felipe Duarte d93be467f7 Update navigation group to 'Gestión' and enhance TelaResource
Changed the navigation group from 'Administración' to 'Gestión' across multiple Filament resources for consistency. In TelaResource, improved the file upload field with image editor options and aspect ratios, and added an image column to the table for better visualization of fabric images.
2026-01-15 10:45:55 -05:00

118 lines
3.6 KiB
PHP

<?php
namespace App\Filament\Resources;
use App\Filament\Resources\ProveedorResource\Pages;
use App\Filament\Resources\ProveedorResource\RelationManagers;
use App\Models\Proveedor;
use Filament\Forms;
use Filament\Forms\Components\Select;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
class ProveedorResource extends Resource
{
protected static ?string $model = Proveedor::class;
protected static ?string $navigationGroup = 'Gestión';
protected static ?string $navigationIcon = 'heroicon-o-users';
public static function canViewAny(): bool
{
return auth()->user()->can('ver proveedores');
}
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('nombre')
->required()
->maxLength(255),
Forms\Components\TextInput::make('nit')
->maxLength(255),
Select::make('categoria')
->label('Categoría')
->options([
'tintoreria' => 'Tintorería',
'talleres' => 'Talleres',
'telas' => 'Telas',
'otros' => 'Otros',
])
->required(),
Forms\Components\TextInput::make('telefono')
->tel()
->maxLength(20)->required(),
Forms\Components\Textarea::make('direccion'),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('nombre')
->label('Nombre')
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('nit')
->label('NIT')
->searchable(),
Tables\Columns\BadgeColumn::make('categoria')
->label('Categoría')
->colors([
'primary' => 'tintoreria',
'success' => 'talleres',
'warning' => 'telas',
'gray' => 'otros',
])
->sortable(),
Tables\Columns\TextColumn::make('telefono')
->label('Teléfono')
->searchable(),
Tables\Columns\TextColumn::make('direccion')
->label('Dirección')
->limit(30)
->toggleable(),
Tables\Columns\TextColumn::make('created_at')
->label('Creado')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->defaultSort('created_at', 'desc')
->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\ListProveedors::route('/'),
'create' => Pages\CreateProveedor::route('/create'),
'edit' => Pages\EditProveedor::route('/{record}/edit'),
];
}
}