mirror of
https://github.com/anna-sara/filament_inventory
synced 2025-10-26 20:17:14 +01:00
Added new typ Literature and updated filters
This commit is contained in:
parent
537441fa8b
commit
581a1fbf74
5 changed files with 162 additions and 51 deletions
|
|
@ -49,7 +49,9 @@ class Reserve extends BasePage implements HasTable
|
||||||
public static function table(Table $table): Table
|
public static function table(Table $table): Table
|
||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
->query( Item::where('can_be_loaned', true)->where('type', "game"))
|
->query( Item::where('can_be_loaned', true)->whereIn('type', ["game", "literature"]))
|
||||||
|
->emptyStateHeading('Inga resultat')
|
||||||
|
->searchable(true)
|
||||||
->columns([
|
->columns([
|
||||||
Grid::make()
|
Grid::make()
|
||||||
->columns(1)
|
->columns(1)
|
||||||
|
|
@ -93,7 +95,9 @@ class Reserve extends BasePage implements HasTable
|
||||||
->default('Ingen uppgift')
|
->default('Ingen uppgift')
|
||||||
->prefix('Ålder: ')
|
->prefix('Ålder: ')
|
||||||
//->suffix(' år'),
|
//->suffix(' år'),
|
||||||
])->extraAttributes(['class' => 'space-y-3 h-full'])
|
])
|
||||||
|
->extraAttributes(['class' => 'space-y-3 h-full'])
|
||||||
|
->hidden(fn ($record) => $record->type === 'literature'),
|
||||||
])->extraAttributes(['class' => 'space-y-3 h-full'])
|
])->extraAttributes(['class' => 'space-y-3 h-full'])
|
||||||
|
|
||||||
])
|
])
|
||||||
|
|
@ -113,11 +117,43 @@ class Reserve extends BasePage implements HasTable
|
||||||
'xl' => 4,
|
'xl' => 4,
|
||||||
])
|
])
|
||||||
->filters([
|
->filters([
|
||||||
SelectFilter::make('category_id')
|
Filter::make('filters')
|
||||||
->multiple()
|
->form([
|
||||||
->preload()
|
Select::make('type')
|
||||||
->label('Kategori')
|
->label('Typ')
|
||||||
->options(Category::all()->where('type', 'game')->pluck('name', 'id')),
|
->live()
|
||||||
|
->options([
|
||||||
|
'game' => __('Game'),
|
||||||
|
'literature' => __('Literature')
|
||||||
|
]),
|
||||||
|
Select::make('category_id')
|
||||||
|
->multiple()
|
||||||
|
->label('Kategorier Litteratur')
|
||||||
|
->options(Category::all()->whereIn('type', 'literature')->pluck('name', 'id'))
|
||||||
|
|
||||||
|
->hidden(fn ($get): string => $get('type') == 'game' || $get('type') == ''),
|
||||||
|
Select::make('category_id')
|
||||||
|
->multiple()
|
||||||
|
->label('Kategorier Spel')
|
||||||
|
->options(Category::all()->whereIn('type', 'game')->pluck('name', 'id'))
|
||||||
|
->hidden(fn ($get): string => $get('type') == 'literature' || $get('type') == ''),
|
||||||
|
])
|
||||||
|
->query(function (Builder $query, array $data): Builder {
|
||||||
|
return $query
|
||||||
|
->when(
|
||||||
|
$data['type'],
|
||||||
|
fn (Builder $query, $type): Builder => $query->where('type', $type),
|
||||||
|
)
|
||||||
|
->when(
|
||||||
|
$data['category_id'],
|
||||||
|
fn (Builder $query, $category_id): Builder => $query->whereIn('category_id', $category_id),
|
||||||
|
);
|
||||||
|
})
|
||||||
|
->columns([
|
||||||
|
'deafult' => 1,
|
||||||
|
'md' => 2,
|
||||||
|
])
|
||||||
|
->columnSpan(2),
|
||||||
Filter::make('reserved')
|
Filter::make('reserved')
|
||||||
->label('Tillgänglig')
|
->label('Tillgänglig')
|
||||||
->query(fn (Builder $query): Builder => $query->where('reserved', false))
|
->query(fn (Builder $query): Builder => $query->where('reserved', false))
|
||||||
|
|
@ -166,34 +202,54 @@ class Reserve extends BasePage implements HasTable
|
||||||
->send();
|
->send();
|
||||||
})
|
})
|
||||||
->hidden(fn ($record) => $record->reserved),
|
->hidden(fn ($record) => $record->reserved),
|
||||||
Action::make('Mer info')
|
Action::make('More info')
|
||||||
->modalSubmitAction(false)
|
->translateLabel()
|
||||||
->button()
|
->modalSubmitAction(false)
|
||||||
->color('primary')
|
|
||||||
->infolist([
|
->infolist([
|
||||||
Section::make('Spel')
|
Section::make('')
|
||||||
->schema([
|
->schema([
|
||||||
ImageEntry::make('image')
|
ImageEntry::make('image')
|
||||||
->label('Bild')
|
->translateLabel()
|
||||||
->width(300)
|
->width(300)
|
||||||
->height('auto'),
|
->height('auto'),
|
||||||
//->disk('local')
|
//->disk('local')
|
||||||
//->visibility('private'),
|
//->visibility('private'),
|
||||||
TextEntry::make('desc')
|
TextEntry::make('desc')
|
||||||
->label('Beskrivning'),
|
->label('Description')
|
||||||
|
->translateLabel(),
|
||||||
TextEntry::make('acquisition_date')
|
TextEntry::make('acquisition_date')
|
||||||
->label('Inköpsdatum'),
|
->translateLabel(),
|
||||||
TextEntry::make('category.name')
|
TextEntry::make('category.name')
|
||||||
->label('Kategori'),
|
->translateLabel(),
|
||||||
TextEntry::make('players')
|
TextEntry::make('players')
|
||||||
->label('Antal spelare'),
|
->translateLabel(),
|
||||||
TextEntry::make('play_time')
|
TextEntry::make('play_time')
|
||||||
->label('Speltid'),
|
->translateLabel(),
|
||||||
TextEntry::make('age')
|
TextEntry::make('age')
|
||||||
->label('Ålder'),
|
->translateLabel(),
|
||||||
|
TextEntry::make('cost')
|
||||||
|
->translateLabel(),
|
||||||
])
|
])
|
||||||
->columns(),
|
->columns()
|
||||||
]),
|
->hidden(fn ($record) => $record->type === 'literature'),
|
||||||
|
Section::make('')
|
||||||
|
->translateLabel()
|
||||||
|
->schema([
|
||||||
|
ImageEntry::make('image')
|
||||||
|
->translateLabel(),
|
||||||
|
TextEntry::make('desc')
|
||||||
|
->label('Description')
|
||||||
|
->translateLabel(),
|
||||||
|
TextEntry::make('acquisition_date')
|
||||||
|
->translateLabel(),
|
||||||
|
TextEntry::make('category.name')
|
||||||
|
->translateLabel(),
|
||||||
|
TextEntry::make('cost')
|
||||||
|
->translateLabel(),
|
||||||
|
])
|
||||||
|
->columns()
|
||||||
|
->hidden(fn ($record) => $record->type === "game"),
|
||||||
|
]),
|
||||||
])
|
])
|
||||||
->bulkActions([
|
->bulkActions([
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,9 @@ class CategoryResource extends Resource
|
||||||
->translateLabel()
|
->translateLabel()
|
||||||
->required()
|
->required()
|
||||||
->options([
|
->options([
|
||||||
'game' => 'Game',
|
'game' => __('Game'),
|
||||||
'item' => 'Item',
|
'literature' => __('Literature'),
|
||||||
|
'item' => __('Item')
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ class ItemResource extends Resource
|
||||||
->options([
|
->options([
|
||||||
'game' => __('Game'),
|
'game' => __('Game'),
|
||||||
'item' => __('Item'),
|
'item' => __('Item'),
|
||||||
|
'literature' => __('Literature')
|
||||||
])
|
])
|
||||||
->default('game')
|
->default('game')
|
||||||
->live(),
|
->live(),
|
||||||
|
|
@ -96,7 +97,7 @@ class ItemResource extends Resource
|
||||||
->minValue(0)
|
->minValue(0)
|
||||||
->maxValue(1000)
|
->maxValue(1000)
|
||||||
->default(0)
|
->default(0)
|
||||||
->hidden(fn ($get): string => $get('type') == 'game'),
|
->hidden(fn ($get): string => $get('type') == 'game' || $get('type') == 'literature' ),
|
||||||
Select::make('category_id')
|
Select::make('category_id')
|
||||||
->label('Category')
|
->label('Category')
|
||||||
->translateLabel()
|
->translateLabel()
|
||||||
|
|
@ -110,23 +111,23 @@ class ItemResource extends Resource
|
||||||
->translateLabel()
|
->translateLabel()
|
||||||
->maxLength(255)
|
->maxLength(255)
|
||||||
->default(null)
|
->default(null)
|
||||||
->hidden(fn ($get): string => $get('type') == 'item'),
|
->hidden(fn ($get): string => $get('type') == 'item' || $get('type') == 'literature' ),
|
||||||
TextInput::make('players')
|
TextInput::make('players')
|
||||||
->label('Players')
|
->label('Players')
|
||||||
->translateLabel()
|
->translateLabel()
|
||||||
->maxLength(255)
|
->maxLength(255)
|
||||||
->default(null)
|
->default(null)
|
||||||
->hidden(fn ($get): string => $get('type') == 'item'),
|
->hidden(fn ($get): string => $get('type') == 'item' || $get('type') == 'literature' ),
|
||||||
TextInput::make('play_time')
|
TextInput::make('play_time')
|
||||||
->label('Play time')
|
->label('Play time')
|
||||||
->translateLabel()
|
->translateLabel()
|
||||||
->maxLength(255)
|
->maxLength(255)
|
||||||
->default(null)
|
->default(null)
|
||||||
->hidden(fn ($get): string => $get('type') == 'item'),
|
->hidden(fn ($get): string => $get('type') == 'item'|| $get('type') == 'literature' ),
|
||||||
Toggle::make('can_be_loaned')
|
Toggle::make('can_be_loaned')
|
||||||
->label('Loanable')
|
->label('Loanable')
|
||||||
->translateLabel()
|
->translateLabel()
|
||||||
->hidden(fn ($get): string => $get('type') == 'game'),
|
->hidden(fn ($get): string => $get('type') == 'game' || $get('type') == 'literature' ),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,20 +171,52 @@ class ItemResource extends Resource
|
||||||
->default(false),
|
->default(false),
|
||||||
])
|
])
|
||||||
->filters([
|
->filters([
|
||||||
SelectFilter::make('type')
|
Filter::make('filters')
|
||||||
->translateLabel()
|
->form([
|
||||||
->multiple()
|
Select::make('type')
|
||||||
->options([
|
->label('Type')
|
||||||
'game' => __('Game'),
|
->live()
|
||||||
'item' => __('Item'),
|
->translateLabel()
|
||||||
]),
|
->options([
|
||||||
SelectFilter::make('category_id')
|
'game' => __('Game'),
|
||||||
->label('Category')
|
'literature' => __('Literature'),
|
||||||
->translateLabel()
|
'item' => __('Item')
|
||||||
->multiple()
|
]),
|
||||||
->options(
|
Select::make('category_id')
|
||||||
Category::all()->pluck('name', 'id'),
|
->multiple()
|
||||||
),
|
->translateLabel()
|
||||||
|
->label('Category literature')
|
||||||
|
->options(Category::all()->whereIn('type', 'literature')->pluck('name', 'id'))
|
||||||
|
->hidden(fn ($get): string => $get('type') == 'game' || $get('type') == 'item'|| $get('type') == ''),
|
||||||
|
Select::make('category_id')
|
||||||
|
->multiple()
|
||||||
|
->translateLabel()
|
||||||
|
->label('Category games')
|
||||||
|
->options(Category::all()->whereIn('type', 'game')->pluck('name', 'id'))
|
||||||
|
->hidden(fn ($get): string => $get('type') == 'literature' || $get('type') == 'item'|| $get('type') == ''),
|
||||||
|
Select::make('category_id')
|
||||||
|
->multiple()
|
||||||
|
->translateLabel()
|
||||||
|
->label('Category items')
|
||||||
|
->options(Category::all()->whereIn('type', 'item')->pluck('name', 'id'))
|
||||||
|
->hidden(fn ($get): string => $get('type') == 'literature' || $get('type') == 'game'|| $get('type') == ''),
|
||||||
|
])
|
||||||
|
->query(function (Builder $query, array $data): Builder {
|
||||||
|
return $query
|
||||||
|
->when(
|
||||||
|
$data['type'],
|
||||||
|
fn (Builder $query, $type): Builder => $query->where('type', $type),
|
||||||
|
)
|
||||||
|
->when(
|
||||||
|
$data['category_id'],
|
||||||
|
fn (Builder $query, $category_id): Builder => $query->whereIn('category_id', $category_id),
|
||||||
|
);
|
||||||
|
})
|
||||||
|
->columns([
|
||||||
|
'deafult' => 1,
|
||||||
|
'md' => 2,
|
||||||
|
])
|
||||||
|
->columnSpan(2),
|
||||||
Filter::make('reserved')
|
Filter::make('reserved')
|
||||||
->label('Available')
|
->label('Available')
|
||||||
->translateLabel()
|
->translateLabel()
|
||||||
|
|
@ -207,9 +240,9 @@ class ItemResource extends Resource
|
||||||
ImageEntry::make('image')
|
ImageEntry::make('image')
|
||||||
->translateLabel()
|
->translateLabel()
|
||||||
->width(300)
|
->width(300)
|
||||||
->height('auto')
|
->height('auto'),
|
||||||
->disk('local')
|
//->disk('local')
|
||||||
->visibility('private'),
|
//->visibility('private'),
|
||||||
TextEntry::make('desc')
|
TextEntry::make('desc')
|
||||||
->label('Description')
|
->label('Description')
|
||||||
->translateLabel(),
|
->translateLabel(),
|
||||||
|
|
@ -227,7 +260,7 @@ class ItemResource extends Resource
|
||||||
->translateLabel(),
|
->translateLabel(),
|
||||||
])
|
])
|
||||||
->columns()
|
->columns()
|
||||||
->hidden(fn ($record) => $record->type === "item"),
|
->hidden(fn ($record) => $record->type === "item" || $record->type === 'literature'),
|
||||||
Section::make('')
|
Section::make('')
|
||||||
->translateLabel()
|
->translateLabel()
|
||||||
->schema([
|
->schema([
|
||||||
|
|
@ -246,8 +279,25 @@ class ItemResource extends Resource
|
||||||
->translateLabel(),
|
->translateLabel(),
|
||||||
])
|
])
|
||||||
->columns()
|
->columns()
|
||||||
->hidden(fn ($record) => $record->type === "game"),
|
->hidden(fn ($record) => $record->type === "game" || $record->type === 'literature'),
|
||||||
]),
|
Section::make('')
|
||||||
|
->translateLabel()
|
||||||
|
->schema([
|
||||||
|
ImageEntry::make('image')
|
||||||
|
->translateLabel(),
|
||||||
|
TextEntry::make('desc')
|
||||||
|
->label('Description')
|
||||||
|
->translateLabel(),
|
||||||
|
TextEntry::make('acquisition_date')
|
||||||
|
->translateLabel(),
|
||||||
|
TextEntry::make('category.name')
|
||||||
|
->translateLabel(),
|
||||||
|
TextEntry::make('cost')
|
||||||
|
->translateLabel(),
|
||||||
|
])
|
||||||
|
->columns()
|
||||||
|
->hidden(fn ($record) => $record->type === "game" || $record->type === 'item'),
|
||||||
|
]),
|
||||||
|
|
||||||
Tables\Actions\EditAction::make()
|
Tables\Actions\EditAction::make()
|
||||||
->button()
|
->button()
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ class CreateItem extends CreateRecord
|
||||||
protected function handleRecordCreation(array $data): Model
|
protected function handleRecordCreation(array $data): Model
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($data['type'] == "game")
|
if ($data['type'] == "game" || $data['type'] == "literature")
|
||||||
{
|
{
|
||||||
$data['can_be_loaned'] = true;
|
$data['can_be_loaned'] = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
6
lang/vendor/filament-panels/sv.json
vendored
6
lang/vendor/filament-panels/sv.json
vendored
|
|
@ -36,5 +36,9 @@
|
||||||
"Total number of games": "Totalt antal spel i lager",
|
"Total number of games": "Totalt antal spel i lager",
|
||||||
"Total number of items": "Totalt antal saker i lager",
|
"Total number of items": "Totalt antal saker i lager",
|
||||||
"Reserved games and items": "Reserverade spel och saker",
|
"Reserved games and items": "Reserverade spel och saker",
|
||||||
"Phone": "Telefonnummer"
|
"Phone": "Telefonnummer",
|
||||||
|
"Literature": "Litteratur",
|
||||||
|
"Category literature": "Kategori litteratur",
|
||||||
|
"Category games": "Kategori spel",
|
||||||
|
"Category items": "Kategori saker"
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue