mirror of
https://github.com/anna-sara/filament_inventory
synced 2025-10-26 23:47:13 +01:00
Added public form for game booking
This commit is contained in:
parent
2aff888fd0
commit
9fabd16e40
5 changed files with 147 additions and 0 deletions
124
app/Filament/Pages/Reserve.php
Normal file
124
app/Filament/Pages/Reserve.php
Normal file
|
|
@ -0,0 +1,124 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Pages;
|
||||||
|
|
||||||
|
use Filament\Pages\BasePage;
|
||||||
|
use App\Filament\Widgets\StatsOverviewWidget;
|
||||||
|
use App\Filament\Resources\ItemResource\Pages;
|
||||||
|
use App\Filament\Resources\ItemResource\RelationManagers;
|
||||||
|
use App\Models\Item;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\Category;
|
||||||
|
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\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\Radio;
|
||||||
|
use Filament\Tables\Enums\FiltersLayout;
|
||||||
|
use Filament\Tables\Filters\Filter;
|
||||||
|
use Filament\Tables\Filters\SelectFilter;
|
||||||
|
use Filament\Actions\CreateAction;
|
||||||
|
use App\Models\Reserveditem;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Filament\Support\Enums\IconPosition;
|
||||||
|
use Filament\Infolists\Components\TextEntry;
|
||||||
|
use Filament\Infolists\Components\Section;
|
||||||
|
use Filament\Tables\Contracts\HasTable;
|
||||||
|
use Filament\Tables\Concerns\InteractsWithTable;
|
||||||
|
|
||||||
|
class Reserve extends BasePage implements HasTable
|
||||||
|
{
|
||||||
|
use InteractsWithTable;
|
||||||
|
|
||||||
|
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||||
|
|
||||||
|
protected static string $view = 'filament.pages.reserve';
|
||||||
|
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->query( Item::where('can_be_loaned', true)->where('type', "game"))
|
||||||
|
->columns([
|
||||||
|
Tables\Columns\TextColumn::make('desc')
|
||||||
|
->label('Description')
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
|
Tables\Columns\ImageColumn::make('image')
|
||||||
|
->label('Image'),
|
||||||
|
Tables\Columns\TextColumn::make('players')
|
||||||
|
->label('Players')
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('play_time')
|
||||||
|
->label('Play Time')
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('age')
|
||||||
|
->label('Age')
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\IconColumn::make('reserved')
|
||||||
|
->label('Available')
|
||||||
|
->falseIcon('heroicon-o-check-badge')
|
||||||
|
->trueIcon('heroicon-o-x-mark')
|
||||||
|
->falseColor('success')
|
||||||
|
->trueColor('danger')
|
||||||
|
->default(false),
|
||||||
|
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
SelectFilter::make('category_id')
|
||||||
|
->label('Category')
|
||||||
|
->multiple()
|
||||||
|
->options(Category::all()->where('type', 'game')->pluck('name', 'id')),
|
||||||
|
Filter::make('reserved')
|
||||||
|
->label('Available')
|
||||||
|
->query(fn (Builder $query): Builder => $query->where('reserved', false))
|
||||||
|
->columnSpanFull()
|
||||||
|
->toggle()
|
||||||
|
],layout: FiltersLayout::AboveContent)
|
||||||
|
->actions([
|
||||||
|
Tables\Actions\Action::make('More info')
|
||||||
|
->modalSubmitAction(false)
|
||||||
|
->infolist([
|
||||||
|
Section::make('Game')
|
||||||
|
->schema([
|
||||||
|
TextEntry::make('desc'),
|
||||||
|
TextEntry::make('acquisition_date'),
|
||||||
|
TextEntry::make('category.name'),
|
||||||
|
TextEntry::make('players'),
|
||||||
|
TextEntry::make('play_time'),
|
||||||
|
TextEntry::make('age'),
|
||||||
|
])
|
||||||
|
->columns(),
|
||||||
|
]),
|
||||||
|
Tables\Actions\Action::make('reserve')
|
||||||
|
->label('Reserve')
|
||||||
|
->button()
|
||||||
|
->color('success')
|
||||||
|
->form([
|
||||||
|
Forms\Components\TextInput::make('username')
|
||||||
|
->label('Name')
|
||||||
|
->required(),
|
||||||
|
Forms\Components\TextInput::make('email')
|
||||||
|
->label('Email')
|
||||||
|
->required(),
|
||||||
|
])
|
||||||
|
->action(function (array $data, Item $record): void {
|
||||||
|
Reserveditem::create([
|
||||||
|
'item_id' => $record->id,
|
||||||
|
'reserved_date' => Carbon::now(),
|
||||||
|
'username' => $data['username'],
|
||||||
|
'email' => $data['email']
|
||||||
|
]);
|
||||||
|
Item::where('id', $record->id)->update(['reserved' => true]);
|
||||||
|
})
|
||||||
|
->hidden(fn ($record) => $record->reserved)
|
||||||
|
])
|
||||||
|
->bulkActions([
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
public/img/logo.png
Normal file
BIN
public/img/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 49 KiB |
|
|
@ -1,3 +1,8 @@
|
||||||
@tailwind base;
|
@tailwind base;
|
||||||
@tailwind components;
|
@tailwind components;
|
||||||
@tailwind utilities;
|
@tailwind utilities;
|
||||||
|
|
||||||
|
|
||||||
|
#reserve-form-container {
|
||||||
|
max-width: 1400px !important;
|
||||||
|
}
|
||||||
15
resources/views/filament/pages/reserve.blade.php
Normal file
15
resources/views/filament/pages/reserve.blade.php
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
|
||||||
|
<div id="reserve-form-container">
|
||||||
|
<nav class="py-2 flex h-16 items-center align-items gap-x-4 bg-white px-4 shadow-sm ring-1 ring-gray-950/5 dark:bg-gray-900 dark:ring-white/10 md:px-6 lg:px-8">
|
||||||
|
<img class=" w-auto h-full" src="/img/logo.png" alt="logo">
|
||||||
|
<h1 class="fi-logo flex text-xl font-bold leading-5 tracking-tight text-gray-950 dark:text-white">vBytes</h1>
|
||||||
|
</nav>
|
||||||
|
<div class="py-12 mx-auto h-full w-full px-4 md:px-6 lg:px-8 max-w-7xl">
|
||||||
|
<h1 class="fi-header-heading text-2xl font-bold tracking-tight text-gray-950 dark:text-white sm:text-3xl">Game booking</h1>
|
||||||
|
<p class="py-4">Welcome! Here you can make a reservation for a game.</p>
|
||||||
|
</div>
|
||||||
|
<div class="mx-auto h-full w-full px-4 md:px-6 lg:px-8 max-w-7xl">
|
||||||
|
{{ $this->table }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
@ -4,6 +4,7 @@ use App\Http\Controllers\ProfileController;
|
||||||
use Illuminate\Foundation\Application;
|
use Illuminate\Foundation\Application;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use Inertia\Inertia;
|
use Inertia\Inertia;
|
||||||
|
use App\Filament\Pages\Reserve;
|
||||||
|
|
||||||
//Route::get('/', function () {
|
//Route::get('/', function () {
|
||||||
// return Inertia::render('Welcome', [
|
// return Inertia::render('Welcome', [
|
||||||
|
|
@ -24,4 +25,6 @@ use Inertia\Inertia;
|
||||||
// Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
|
// Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
|
||||||
//});
|
//});
|
||||||
|
|
||||||
|
Route::get('reserve', Reserve::class);
|
||||||
|
|
||||||
require __DIR__.'/auth.php';
|
require __DIR__.'/auth.php';
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue