ranjith-dev #663
79
app/Filament/Pages/GateOutEntry.php
Normal file
79
app/Filament/Pages/GateOutEntry.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Plant;
|
||||
use App\Models\VisitorEntry;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class GateOutEntry extends Page implements HasForms
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.gate-out-entry';
|
||||
|
||||
protected static ?string $navigationGroup = 'Gate Entry';
|
||||
|
||||
|
||||
public $pId, $invoiceNumber;
|
||||
|
||||
public array $invoiceOverviewData = [];
|
||||
|
||||
public array $filters = [];
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
Section::make('') // You can give your section a title or leave it blank
|
||||
->schema([
|
||||
TextInput::make('scan_out_gate_pass')
|
||||
->label('Scan Out Gate Pass')
|
||||
->required()
|
||||
->reactive()
|
||||
->extraAttributes([
|
||||
'wire:keydown.enter' => 'processGatePass($event.target.value)',
|
||||
]),
|
||||
])
|
||||
->columns(5)
|
||||
]);
|
||||
}
|
||||
|
||||
public function processGatePass($gatePass)
|
||||
{
|
||||
$entry = VisitorEntry::where('register_id', $gatePass)->first();
|
||||
|
||||
if ($entry) {
|
||||
$entry->out_time = now();
|
||||
$entry->save();
|
||||
|
||||
Notification::make()
|
||||
->title('Gate Pass Processed')
|
||||
->body('Gate pass has been successfully processed. Visitor marked as exited.')
|
||||
->success()
|
||||
->send();
|
||||
$this->filters['scan_out_gate_pass'] = '';
|
||||
} else {
|
||||
Notification::make()
|
||||
->title('Invalid Gate Pass')
|
||||
->body('The scanned gate pass is not valid. Please try again.')
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view gate entry page');
|
||||
}
|
||||
}
|
||||
@@ -228,6 +228,7 @@ class PermissionSeeder extends Seeder
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view import asrs item validation']);
|
||||
Permission::updateOrCreate(['name' => 'view export asrs item validation']);
|
||||
Permission::updateOrCreate(['name' => 'view gate entry page']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
10
resources/views/filament/pages/gate-out-entry.blade.php
Normal file
10
resources/views/filament/pages/gate-out-entry.blade.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<x-filament-panels::page>
|
||||
|
||||
<div class="space-y-4">
|
||||
{{-- Render the Select form fields --}}
|
||||
<div class="space-y-4">
|
||||
{{ $this->form }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</x-filament-panels::page>
|
||||
Reference in New Issue
Block a user