Compare commits
194 Commits
ranjith-de
...
711218521c
| Author | SHA1 | Date | |
|---|---|---|---|
| 711218521c | |||
| c3c77fa737 | |||
| bac841c3fa | |||
| 631cfedef2 | |||
| 4aa0acb85d | |||
|
|
91cad60e02 | ||
| e0cfe7ccea | |||
| 3c8bcb2e9e | |||
| ef62ca360b | |||
| 16d7f74115 | |||
| 9fe342df80 | |||
| b421692560 | |||
| c17dc86d48 | |||
| 129f9169f4 | |||
| 6532f2d075 | |||
| fb965f3871 | |||
| e609b32954 | |||
| 3c59e06fe7 | |||
| aee5a8cb50 | |||
| 6e8b02e742 | |||
| 1988dfcc0e | |||
| df0904e6c1 | |||
| a2958c999c | |||
| 051616da25 | |||
| 8cf1063e2a | |||
| b7ec4f4c1a | |||
| f26209f3db | |||
| 23914944ca | |||
| e4b951ff77 | |||
| 2c8efe351b | |||
| f63ec1feee | |||
| c63b24e249 | |||
| 549c22f0e5 | |||
| bf055b7672 | |||
| 2eaf01bec8 | |||
| b6478b5feb | |||
| 6d32be91f7 | |||
| 525d951df7 | |||
| 1e208bfd7f | |||
| 8b3a65c4f3 | |||
| 089678dfb3 | |||
| afef84e0c7 | |||
| 7c3845ce7c | |||
| 97c38d9554 | |||
| 2571d0ac57 | |||
| c2b7c43bf0 | |||
| d993b64906 | |||
| 0c9d5a7964 | |||
| aa0b94a975 | |||
| ae0bc9dcd6 | |||
| 5d8e5d13f5 | |||
| 6747abb2db | |||
| d27ab1d98e | |||
| 0f38a9ff1b | |||
| 667682201a | |||
| e20caa54c7 | |||
| efa6410cd9 | |||
| eae7e76ea4 | |||
| 30e4415af9 | |||
| 40014570c9 | |||
| c5e45cd6dd | |||
| 2d40e51e78 | |||
| 98a3c5bc8e | |||
| e969e54f59 | |||
| 6bad120e70 | |||
| 02dea13222 | |||
| 07c642e3bd | |||
| 33e3b247b3 | |||
| 0bcc8d2113 | |||
| ff607695bc | |||
| 006857ec89 | |||
| 107e8cf505 | |||
| 49d5dfb664 | |||
| cf097255a0 | |||
| 27223612d3 | |||
| 22de1ba081 | |||
| d7c2fc3ff9 | |||
| 29a7a66ff4 | |||
| 5f87467dbf | |||
| c01df679a0 | |||
| 4b653f6bb0 | |||
| a877623567 | |||
| e8a6e88eac | |||
| ab49a0fc7c | |||
| e320e4486f | |||
| 4b5cdef55a | |||
| 82a022d3b4 | |||
| 7ec116ca0b | |||
| 048f069dd7 | |||
| b83e26c9d6 | |||
| 945d50c504 | |||
| ae0758a9c0 | |||
| 238d7bdfa7 | |||
| be1e7f36b2 | |||
| 165b7e6a77 | |||
| d0269a646c | |||
| 3eccb1c7d5 | |||
| 83888054e9 | |||
| 22e2fbd25d | |||
| d5d1243d5c | |||
| 2d2d3ac8c5 | |||
| 6e9e57682c | |||
| 3fa6ca578b | |||
| bc43d5ddf1 | |||
| 201c55121e | |||
| aa91bd80de | |||
| d4fc6f6f33 | |||
| dade6a3c0c | |||
| d8aea01b26 | |||
| a690faf6d7 | |||
| dd6cbd92a2 | |||
| b54a9af78b | |||
| 57f059aca8 | |||
| 5688e93862 | |||
| 8b556d3c9c | |||
| 091aaaa0d7 | |||
| 9dd5d04b3c | |||
| 4ac3eb4f2f | |||
| bcd493901c | |||
| af3259a842 | |||
| 6f41238b1e | |||
| 8779e66a18 | |||
| e0384780dc | |||
| afbbfe2aca | |||
| 4fb04c9fa8 | |||
| 656c58999c | |||
| 102bc62805 | |||
| ef1ad62749 | |||
| 1e0193e6c9 | |||
| 18c203552c | |||
| 61190edcce | |||
| 62774aec0f | |||
| 44e58d2d78 | |||
| 3ac4f88155 | |||
| 818f8a3e08 | |||
| 86798212d0 | |||
| 837bd58177 | |||
| d8b29ba000 | |||
| d1db3e0dad | |||
| f274de00e1 | |||
| f9c6405b61 | |||
| 7ec34a04fc | |||
| 9256e1ed12 | |||
| b334ba60fa | |||
| 8c81c140d1 | |||
| 5ff8acac74 | |||
| 2f2bab37d4 | |||
| a8d72923ae | |||
| e39ab23142 | |||
| 2373e1d427 | |||
| baa165e285 | |||
| 53e671d612 | |||
| 58be303cfe | |||
| a1c39c5f0e | |||
| 41e8c04b9d | |||
| 6a30fbc8f2 | |||
| 9e57461d3a | |||
| ab5a6b94c9 | |||
| 84b78ea0c1 | |||
| 5e46b080c5 | |||
| 17f337e8db | |||
| 2781d57e3f | |||
| 5628e8abd4 | |||
| e56733ce44 | |||
| b3f32f6813 | |||
| b2937ccfa8 | |||
| 026e4982b8 | |||
| 6478bc3722 | |||
| 1ab7ed2da9 | |||
| 9ecd04f0e3 | |||
| 53179ea538 | |||
| b4e24c581e | |||
| 4938fa62a7 | |||
| 01f6288c63 | |||
| c9c7c38088 | |||
| 90cfe9ef0d | |||
| aa806f2fe3 | |||
| 0eb6f76ca6 | |||
| 73366ccd70 | |||
| acbecedce9 | |||
| 614d89932b | |||
| c839c6fdbc | |||
| d9445a9d4b | |||
| 50476c8a2c | |||
| c57cfe71ca | |||
| 96c08c34c1 | |||
| 19cf7c8edd | |||
| 66086dd2d7 | |||
| 5da724c9a4 | |||
| 6b723c0929 | |||
| 8e20d0732d | |||
| 1d8fb1c9aa | |||
| 33bbce47ba | |||
| 860ff96134 |
@@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Exports;
|
|
||||||
|
|
||||||
use App\Models\EmployeeMaster;
|
|
||||||
use Filament\Actions\Exports\ExportColumn;
|
|
||||||
use Filament\Actions\Exports\Exporter;
|
|
||||||
use Filament\Actions\Exports\Models\Export;
|
|
||||||
|
|
||||||
class EmployeeMasterExporter extends Exporter
|
|
||||||
{
|
|
||||||
protected static ?string $model = EmployeeMaster::class;
|
|
||||||
|
|
||||||
public static function getColumns(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
ExportColumn::make('id')
|
|
||||||
->label('ID'),
|
|
||||||
ExportColumn::make('plant.name'),
|
|
||||||
ExportColumn::make('name'),
|
|
||||||
ExportColumn::make('code'),
|
|
||||||
ExportColumn::make('department'),
|
|
||||||
ExportColumn::make('designation'),
|
|
||||||
ExportColumn::make('email'),
|
|
||||||
ExportColumn::make('mobile_number'),
|
|
||||||
ExportColumn::make('created_at'),
|
|
||||||
ExportColumn::make('updated_at'),
|
|
||||||
ExportColumn::make('created_by'),
|
|
||||||
ExportColumn::make('updated_by'),
|
|
||||||
ExportColumn::make('deleted_at'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Export $export): string
|
|
||||||
{
|
|
||||||
$body = 'Your employee master export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
|
||||||
|
|
||||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
|
||||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $body;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Imports;
|
|
||||||
|
|
||||||
use App\Models\EmployeeMaster;
|
|
||||||
use Filament\Actions\Imports\ImportColumn;
|
|
||||||
use Filament\Actions\Imports\Importer;
|
|
||||||
use Filament\Actions\Imports\Models\Import;
|
|
||||||
|
|
||||||
class EmployeeMasterImporter extends Importer
|
|
||||||
{
|
|
||||||
protected static ?string $model = EmployeeMaster::class;
|
|
||||||
|
|
||||||
public static function getColumns(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
ImportColumn::make('plant')
|
|
||||||
->requiredMapping()
|
|
||||||
->relationship()
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('name'),
|
|
||||||
ImportColumn::make('code'),
|
|
||||||
ImportColumn::make('department'),
|
|
||||||
ImportColumn::make('designation'),
|
|
||||||
ImportColumn::make('email')
|
|
||||||
->rules(['email']),
|
|
||||||
ImportColumn::make('mobile_number'),
|
|
||||||
ImportColumn::make('created_by'),
|
|
||||||
ImportColumn::make('updated_by'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function resolveRecord(): ?EmployeeMaster
|
|
||||||
{
|
|
||||||
// return EmployeeMaster::firstOrNew([
|
|
||||||
// // Update existing records, matching them by `$this->data['column_name']`
|
|
||||||
// 'email' => $this->data['email'],
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
return new EmployeeMaster();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Import $import): string
|
|
||||||
{
|
|
||||||
$body = 'Your employee master import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
|
||||||
|
|
||||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
|
||||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $body;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,217 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources;
|
|
||||||
|
|
||||||
use App\Filament\Exports\EmployeeMasterExporter;
|
|
||||||
use App\Filament\Imports\EmployeeMasterImporter;
|
|
||||||
use App\Filament\Resources\EmployeeMasterResource\Pages;
|
|
||||||
use App\Filament\Resources\EmployeeMasterResource\RelationManagers;
|
|
||||||
use App\Models\EmployeeMaster;
|
|
||||||
use Filament\Facades\Filament;
|
|
||||||
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\Tables\Actions\ExportAction;
|
|
||||||
use Filament\Tables\Actions\ImportAction;
|
|
||||||
use Illuminate\Validation\Rule;
|
|
||||||
|
|
||||||
class EmployeeMasterResource extends Resource
|
|
||||||
{
|
|
||||||
protected static ?string $model = EmployeeMaster::class;
|
|
||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
|
||||||
{
|
|
||||||
return $form
|
|
||||||
->schema([
|
|
||||||
Forms\Components\Select::make('plant_id')
|
|
||||||
->label('Plant')
|
|
||||||
->relationship('plant', 'name')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\TextInput::make('name')
|
|
||||||
->label('Name')
|
|
||||||
->required()
|
|
||||||
->reactive()
|
|
||||||
->extraInputAttributes([
|
|
||||||
'oninput' => 'this.value = this.value.replace(/[^a-zA-Z\s]/g, "")',
|
|
||||||
]),
|
|
||||||
Forms\Components\TextInput::make('code')
|
|
||||||
->label('ID')
|
|
||||||
->extraInputAttributes([
|
|
||||||
'oninput' => 'this.value = this.value.replace(/[^a-zA-Z0-9]/g, "")',])
|
|
||||||
->required()
|
|
||||||
->unique(
|
|
||||||
table: 'employee_masters',
|
|
||||||
column: 'code',
|
|
||||||
ignoreRecord: true
|
|
||||||
)
|
|
||||||
->validationMessages([
|
|
||||||
'unique' => 'Duplicate employee code already exists.',
|
|
||||||
]),
|
|
||||||
Forms\Components\TextInput::make('department')
|
|
||||||
->label('Department')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\TextInput::make('designation')
|
|
||||||
->label('Designation')
|
|
||||||
->extraInputAttributes([
|
|
||||||
'oninput' => 'this.value = this.value.replace(/[^a-zA-Z\s]/g, "")',])
|
|
||||||
->required(),
|
|
||||||
Forms\Components\TextInput::make('email')
|
|
||||||
->label('Email')
|
|
||||||
->email()
|
|
||||||
->required(),
|
|
||||||
Forms\Components\TextInput::make('mobile_number')
|
|
||||||
->label('Mobile Number')
|
|
||||||
->length(10)
|
|
||||||
->reactive()
|
|
||||||
->extraInputAttributes([
|
|
||||||
'oninput' => 'this.value = this.value.replace(/[^0-9]/g, "").slice(0, 10)', // blocks non-numbers + limits to 10 chars
|
|
||||||
'maxlength' => 10,
|
|
||||||
])
|
|
||||||
->required()
|
|
||||||
->unique(
|
|
||||||
table: 'employee_masters',
|
|
||||||
column: 'mobile_number',
|
|
||||||
ignoreRecord: true
|
|
||||||
)
|
|
||||||
->validationMessages([
|
|
||||||
'unique' => 'Duplicate mobile number already exists.',
|
|
||||||
]),
|
|
||||||
Forms\Components\Hidden::make('created_by')
|
|
||||||
->label('Created by')
|
|
||||||
->default(Filament::auth()->user()?->name ?? ''),
|
|
||||||
Forms\Components\Hidden::make('updated_by')
|
|
||||||
->label('Updated by')
|
|
||||||
->default(Filament::auth()->user()?->name ?? ''),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
|
||||||
{
|
|
||||||
return $table
|
|
||||||
->columns([
|
|
||||||
Tables\Columns\TextColumn::make('No.')
|
|
||||||
->label('No.')
|
|
||||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
|
||||||
$paginator = $livewire->getTableRecords();
|
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
|
||||||
})
|
|
||||||
->alignCenter(),
|
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
|
||||||
->numeric()
|
|
||||||
->sortable()
|
|
||||||
->alignCenter(),
|
|
||||||
Tables\Columns\TextColumn::make('name')
|
|
||||||
->label('Name')
|
|
||||||
->sortable()
|
|
||||||
->alignCenter()
|
|
||||||
->searchable(),
|
|
||||||
Tables\Columns\TextColumn::make('code')
|
|
||||||
->label('Employee ID')
|
|
||||||
->sortable()
|
|
||||||
->alignCenter()
|
|
||||||
->searchable(),
|
|
||||||
Tables\Columns\TextColumn::make('department')
|
|
||||||
->label('Department')
|
|
||||||
->sortable()
|
|
||||||
->alignCenter()
|
|
||||||
->searchable(),
|
|
||||||
Tables\Columns\TextColumn::make('designation')
|
|
||||||
->label('Designation')
|
|
||||||
->sortable()
|
|
||||||
->alignCenter()
|
|
||||||
->searchable(),
|
|
||||||
Tables\Columns\TextColumn::make('email')
|
|
||||||
->label('Email')
|
|
||||||
->sortable()
|
|
||||||
->alignCenter()
|
|
||||||
->searchable(),
|
|
||||||
Tables\Columns\TextColumn::make('mobile_number')
|
|
||||||
->label('Mobile Number')
|
|
||||||
->sortable()
|
|
||||||
->alignCenter()
|
|
||||||
->searchable(),
|
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
|
||||||
->dateTime()
|
|
||||||
->sortable()
|
|
||||||
->alignCenter(),
|
|
||||||
Tables\Columns\TextColumn::make('updated_at')
|
|
||||||
->dateTime()
|
|
||||||
->sortable()
|
|
||||||
->toggleable(isToggledHiddenByDefault: true)
|
|
||||||
->alignCenter(),
|
|
||||||
Tables\Columns\TextColumn::make('created_by')
|
|
||||||
->label('Created by')
|
|
||||||
->sortable()
|
|
||||||
->alignCenter(),
|
|
||||||
Tables\Columns\TextColumn::make('updated_by')
|
|
||||||
->label('Updated by')
|
|
||||||
->sortable()
|
|
||||||
->toggleable(isToggledHiddenByDefault: true)
|
|
||||||
->alignCenter(),
|
|
||||||
Tables\Columns\TextColumn::make('deleted_at')
|
|
||||||
->dateTime()
|
|
||||||
->sortable()
|
|
||||||
->toggleable(isToggledHiddenByDefault: true)
|
|
||||||
->alignCenter(),
|
|
||||||
])
|
|
||||||
->filters([
|
|
||||||
Tables\Filters\TrashedFilter::make(),
|
|
||||||
])
|
|
||||||
->actions([
|
|
||||||
Tables\Actions\ViewAction::make(),
|
|
||||||
Tables\Actions\EditAction::make(),
|
|
||||||
])
|
|
||||||
->bulkActions([
|
|
||||||
Tables\Actions\BulkActionGroup::make([
|
|
||||||
Tables\Actions\DeleteBulkAction::make(),
|
|
||||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
|
||||||
Tables\Actions\RestoreBulkAction::make(),
|
|
||||||
]),
|
|
||||||
])
|
|
||||||
->headerActions([
|
|
||||||
ImportAction::make()
|
|
||||||
->importer(EmployeeMasterImporter::class)
|
|
||||||
->visible(function() {
|
|
||||||
return Filament::auth()->user()->can('view import employee master');
|
|
||||||
}),
|
|
||||||
ExportAction::make()
|
|
||||||
->exporter(EmployeeMasterExporter::class)
|
|
||||||
->visible(function() {
|
|
||||||
return Filament::auth()->user()->can('view export employee master');
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getRelations(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
//
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getPages(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'index' => Pages\ListEmployeeMasters::route('/'),
|
|
||||||
'create' => Pages\CreateEmployeeMaster::route('/create'),
|
|
||||||
'view' => Pages\ViewEmployeeMaster::route('/{record}'),
|
|
||||||
'edit' => Pages\EditEmployeeMaster::route('/{record}/edit'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getEloquentQuery(): Builder
|
|
||||||
{
|
|
||||||
return parent::getEloquentQuery()
|
|
||||||
->withoutGlobalScopes([
|
|
||||||
SoftDeletingScope::class,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\EmployeeMasterResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\EmployeeMasterResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
|
||||||
|
|
||||||
class CreateEmployeeMaster extends CreateRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = EmployeeMasterResource::class;
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\EmployeeMasterResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\EmployeeMasterResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\EditRecord;
|
|
||||||
|
|
||||||
class EditEmployeeMaster extends EditRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = EmployeeMasterResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Actions\ViewAction::make(),
|
|
||||||
Actions\DeleteAction::make(),
|
|
||||||
Actions\ForceDeleteAction::make(),
|
|
||||||
Actions\RestoreAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\EmployeeMasterResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\EmployeeMasterResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\ListRecords;
|
|
||||||
|
|
||||||
class ListEmployeeMasters extends ListRecords
|
|
||||||
{
|
|
||||||
protected static string $resource = EmployeeMasterResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Actions\CreateAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\EmployeeMasterResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\EmployeeMasterResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\ViewRecord;
|
|
||||||
|
|
||||||
class ViewEmployeeMaster extends ViewRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = EmployeeMasterResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Actions\EditAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -82,9 +82,6 @@ class ItemResource extends Resource
|
|||||||
Forms\Components\TextInput::make('category')
|
Forms\Components\TextInput::make('category')
|
||||||
->label('Category')
|
->label('Category')
|
||||||
->placeholder('Scan the Category'),
|
->placeholder('Scan the Category'),
|
||||||
Forms\Components\TextInput::make('category')
|
|
||||||
->label('Category')
|
|
||||||
->placeholder('Scan the Category'),
|
|
||||||
Forms\Components\TextInput::make('code')
|
Forms\Components\TextInput::make('code')
|
||||||
->required()
|
->required()
|
||||||
->placeholder('Scan the valid code')
|
->placeholder('Scan the valid code')
|
||||||
|
|||||||
@@ -1,276 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources;
|
|
||||||
|
|
||||||
use App\Filament\Resources\VisitorEntryResource\Pages;
|
|
||||||
use App\Filament\Resources\VisitorEntryResource\RelationManagers;
|
|
||||||
use App\Models\VisitorEntry;
|
|
||||||
use Filament\Facades\Filament;
|
|
||||||
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;
|
|
||||||
|
|
||||||
class VisitorEntryResource extends Resource
|
|
||||||
{
|
|
||||||
protected static ?string $model = VisitorEntry::class;
|
|
||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
|
||||||
{
|
|
||||||
return $form
|
|
||||||
->schema([
|
|
||||||
Forms\Components\TextInput::make('mobile_number')
|
|
||||||
->label('Mobile Number')
|
|
||||||
->length(10)
|
|
||||||
->reactive()
|
|
||||||
->extraInputAttributes([
|
|
||||||
'oninput' => 'this.value = this.value.replace(/[^0-9]/g, "").slice(0, 10)', // blocks non-numbers + limits to 10 chars
|
|
||||||
'maxlength' => 10,
|
|
||||||
])
|
|
||||||
->required()
|
|
||||||
->extraAttributes([
|
|
||||||
'id' => 'mobile_number_input',
|
|
||||||
'x-data' => '{ value: "" }',
|
|
||||||
'x-model' => 'value',
|
|
||||||
'wire:keydown.enter.prevent' => 'processMobile(value)',
|
|
||||||
]),
|
|
||||||
Forms\Components\TextInput::make('name')
|
|
||||||
->label('Name')
|
|
||||||
->required()
|
|
||||||
->reactive()
|
|
||||||
->extraInputAttributes([
|
|
||||||
'oninput' => 'this.value = this.value.replace(/[^a-zA-Z\s]/g, "")',
|
|
||||||
]),
|
|
||||||
Forms\Components\Select::make('type')
|
|
||||||
->label('Type')
|
|
||||||
->reactive()
|
|
||||||
->options([
|
|
||||||
'Student' => 'Student',
|
|
||||||
'Consultant' => 'Consultant',
|
|
||||||
'Vendor' => 'Vendor',
|
|
||||||
'Other' => 'Other',
|
|
||||||
])
|
|
||||||
->required()
|
|
||||||
->dehydrateStateUsing(function ($state, callable $get) {
|
|
||||||
return $state == 'Other'
|
|
||||||
? $get('other_type')
|
|
||||||
: $state;
|
|
||||||
}),
|
|
||||||
Forms\Components\TextInput::make('other_type')
|
|
||||||
->label('Specify Type')
|
|
||||||
->reactive()
|
|
||||||
->visible(fn (callable $get) => $get('type') == 'Other')
|
|
||||||
->required(fn (callable $get) => $get('type') == 'Other')
|
|
||||||
->dehydrated(false),
|
|
||||||
Forms\Components\TextInput::make('company')
|
|
||||||
->label('Company')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Select::make('department')
|
|
||||||
->label('Employee Department')
|
|
||||||
->options(
|
|
||||||
\App\Models\EmployeeMaster::distinct()
|
|
||||||
->pluck('department', 'department')
|
|
||||||
)
|
|
||||||
->required()
|
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function (callable $set) {
|
|
||||||
$set('employee_master_id', null);
|
|
||||||
$set('code', null);
|
|
||||||
}),
|
|
||||||
// Forms\Components\Select::make('employee_master_id')
|
|
||||||
// ->label('Recipient Employee')
|
|
||||||
// ->required()
|
|
||||||
// ->options(function (callable $get) {
|
|
||||||
// $department = $get('department');
|
|
||||||
|
|
||||||
// if (!$department) {
|
|
||||||
// return [];
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return \App\Models\EmployeeMaster::where('department', $department)
|
|
||||||
// ->pluck('name', 'id');
|
|
||||||
// })
|
|
||||||
// ->reactive()
|
|
||||||
// ->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
|
||||||
// $department = $get('department');
|
|
||||||
|
|
||||||
// $employee = \App\Models\EmployeeMaster::where('id', $state)
|
|
||||||
// ->where('department', $department)
|
|
||||||
// ->first();
|
|
||||||
|
|
||||||
// $set('code', $employee ? $employee->code : '');
|
|
||||||
// }),
|
|
||||||
|
|
||||||
Forms\Components\Select::make('employee_master_id')
|
|
||||||
->label('Recipient Employee')
|
|
||||||
->required()
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$department = $get('department');
|
|
||||||
// Always load ALL employees, filter by department if set
|
|
||||||
if ($department) {
|
|
||||||
return \App\Models\EmployeeMaster::where('department', $department)
|
|
||||||
->pluck('name', 'id');
|
|
||||||
}
|
|
||||||
// Fallback: load all so fill() can always match the ID
|
|
||||||
return \App\Models\EmployeeMaster::pluck('name', 'id');
|
|
||||||
})
|
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function (callable $set, ?string $state) {
|
|
||||||
$employee = \App\Models\EmployeeMaster::find($state);
|
|
||||||
$set('code', $employee?->code ?? '');
|
|
||||||
}),
|
|
||||||
|
|
||||||
Forms\Components\TextInput::make('code')
|
|
||||||
->label('Employee Code')
|
|
||||||
->readOnly(),
|
|
||||||
Forms\Components\Textarea::make('purpose_of_visit')
|
|
||||||
->label('Purpose of Visit')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\TextInput::make('number_of_person')
|
|
||||||
->numeric()
|
|
||||||
->default(1)
|
|
||||||
->required(),
|
|
||||||
Forms\Components\DateTimePicker::make('in_time')
|
|
||||||
->label('In Time'),
|
|
||||||
Forms\Components\DateTimePicker::make('out_time')
|
|
||||||
->label('Out Time'),
|
|
||||||
Forms\Components\View::make('components.webcam-field')
|
|
||||||
->columnSpanFull(),
|
|
||||||
Forms\Components\Hidden::make('photo'),
|
|
||||||
Forms\Components\Hidden::make('created_by')
|
|
||||||
->label('created_by')
|
|
||||||
->default(Filament::auth()->user()?->name),
|
|
||||||
Forms\Components\Hidden::make('updated_by')
|
|
||||||
->label('updated_by')
|
|
||||||
->default(Filament::auth()->user()?->name),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
|
||||||
{
|
|
||||||
return $table
|
|
||||||
->columns([
|
|
||||||
Tables\Columns\TextColumn::make('No.')
|
|
||||||
->label('NO')
|
|
||||||
->alignCenter()
|
|
||||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
|
||||||
$paginator = $livewire->getTableRecords();
|
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
|
||||||
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
|
||||||
}),
|
|
||||||
Tables\Columns\ImageColumn::make('photo')
|
|
||||||
->label('Photo')
|
|
||||||
->disk('public')
|
|
||||||
->height(50)
|
|
||||||
->width(50)
|
|
||||||
// ->defaultImageUrl('https://ui-avatars.com/api/?name=Visitor&background=555&color=fff')
|
|
||||||
->defaultImageUrl(asset('images/profile.png'))
|
|
||||||
->alignCenter()
|
|
||||||
->extraImgAttributes(['style' => 'border-radius: 6px; object-fit: cover;']),
|
|
||||||
Tables\Columns\TextColumn::make('type')
|
|
||||||
->label('Visitor Type')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('name')
|
|
||||||
->label('Visitor Name')
|
|
||||||
->sortable()
|
|
||||||
->alignCenter()
|
|
||||||
->searchable(),
|
|
||||||
Tables\Columns\TextColumn::make('mobile_number')
|
|
||||||
->label('Visitor Mobile Number')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('employeeMaster.name')
|
|
||||||
->label('Recipient Name')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('employeeMaster.code')
|
|
||||||
->label('Receipient ID')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('employeeMaster.department')
|
|
||||||
->label('Receipient Department')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('number_of_person')
|
|
||||||
->label('Number of Person')
|
|
||||||
->numeric()
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('in_time')
|
|
||||||
->label('In Time')
|
|
||||||
->dateTime()
|
|
||||||
->sortable()
|
|
||||||
->alignCenter(),
|
|
||||||
Tables\Columns\TextColumn::make('out_time')
|
|
||||||
->label('Out Time')
|
|
||||||
->dateTime()
|
|
||||||
->sortable()
|
|
||||||
->alignCenter(),
|
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
|
||||||
->label('Created At')
|
|
||||||
->dateTime()
|
|
||||||
->sortable()
|
|
||||||
->toggleable(isToggledHiddenByDefault: true)
|
|
||||||
->alignCenter(),
|
|
||||||
Tables\Columns\TextColumn::make('updated_at')
|
|
||||||
->label('Updated At')
|
|
||||||
->dateTime()
|
|
||||||
->sortable()
|
|
||||||
->toggleable(isToggledHiddenByDefault: true)
|
|
||||||
->alignCenter(),
|
|
||||||
Tables\Columns\TextColumn::make('deleted_at')
|
|
||||||
->label('Deleted At')
|
|
||||||
->dateTime()
|
|
||||||
->sortable()
|
|
||||||
->toggleable(isToggledHiddenByDefault: true)
|
|
||||||
->alignCenter(),
|
|
||||||
])
|
|
||||||
->filters([
|
|
||||||
Tables\Filters\TrashedFilter::make(),
|
|
||||||
])
|
|
||||||
->actions([
|
|
||||||
Tables\Actions\ViewAction::make(),
|
|
||||||
Tables\Actions\EditAction::make(),
|
|
||||||
])
|
|
||||||
->bulkActions([
|
|
||||||
Tables\Actions\BulkActionGroup::make([
|
|
||||||
Tables\Actions\DeleteBulkAction::make(),
|
|
||||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
|
||||||
Tables\Actions\RestoreBulkAction::make(),
|
|
||||||
]),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getRelations(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
//
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getPages(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'index' => Pages\ListVisitorEntries::route('/'),
|
|
||||||
'create' => Pages\CreateVisitorEntry::route('/create'),
|
|
||||||
'view' => Pages\ViewVisitorEntry::route('/{record}'),
|
|
||||||
'edit' => Pages\EditVisitorEntry::route('/{record}/edit'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getEloquentQuery(): Builder
|
|
||||||
{
|
|
||||||
return parent::getEloquentQuery()
|
|
||||||
->withoutGlobalScopes([
|
|
||||||
SoftDeletingScope::class,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,150 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\VisitorEntryResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\VisitorEntryResource;
|
|
||||||
use App\Models\EmployeeMaster;
|
|
||||||
use App\Models\VisitorEntry;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
|
||||||
use Livewire\Attributes\On;
|
|
||||||
use Storage;
|
|
||||||
|
|
||||||
class CreateVisitorEntry extends CreateRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = VisitorEntryResource::class;
|
|
||||||
|
|
||||||
public $capturedPhoto;
|
|
||||||
|
|
||||||
// #[On('photo-captured')]
|
|
||||||
// public function handlePhotoCapture(string $photo): void
|
|
||||||
// {
|
|
||||||
// // Puts the Base64 photo into the form's data array
|
|
||||||
// $this->data['photo'] = $photo;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public function processMobile($mobile)
|
|
||||||
{
|
|
||||||
$visitor = VisitorEntry::where('mobile_number', $mobile)->latest()->first();
|
|
||||||
|
|
||||||
if ($visitor) {
|
|
||||||
|
|
||||||
$employee = EmployeeMaster::where('id', $visitor->employee_master_id)->first();
|
|
||||||
|
|
||||||
$this->form->fill([
|
|
||||||
'mobile_number' => $mobile ?? '',
|
|
||||||
'name' => $visitor->name ?? '',
|
|
||||||
'company' => $visitor->company ?? '',
|
|
||||||
'type' => $visitor->type ?? '',
|
|
||||||
'department' => $employee->department ?? '',
|
|
||||||
'employee_master_id' => $visitor->employee_master_id->name ?? '',
|
|
||||||
'code' => $employee->code ?? '',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
$this->form->fill([
|
|
||||||
'mobile_number' => $mobile ?? '',
|
|
||||||
'name' => $visitor->name ?? '',
|
|
||||||
'company' => $visitor->company ?? '',
|
|
||||||
'type' => $visitor->type ?? '',
|
|
||||||
'department' => $employee->department ?? '',
|
|
||||||
'employee_master_id' => $visitor->employee_master_id->name ?? '',
|
|
||||||
'code' => $employee->code ?? '',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// protected function mutateFormDataBeforeCreate(array $data): array
|
|
||||||
// {
|
|
||||||
// if (
|
|
||||||
// !empty($data['photo']) &&
|
|
||||||
// str_starts_with($data['photo'], 'data:image')
|
|
||||||
// ) {
|
|
||||||
// // Step A: Strip the "data:image/jpeg;base64," prefix
|
|
||||||
// $imageData = explode(',', $data['photo'])[1];
|
|
||||||
|
|
||||||
// // Step B: Generate a unique filename
|
|
||||||
// $filename = 'visitor_' . time() . '_' . uniqid() . '.jpg';
|
|
||||||
|
|
||||||
// // Step C: Decode Base64 and save as a real .jpg file
|
|
||||||
// $path = 'visitor-photos/' . $filename;
|
|
||||||
// Storage::disk('public')->put($path, base64_decode($imageData));
|
|
||||||
|
|
||||||
// // Step D: Replace the Base64 string with just the file path
|
|
||||||
// $data['photo'] = $path;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return $data;
|
|
||||||
// }
|
|
||||||
|
|
||||||
#[On('photo-captured')]
|
|
||||||
public function handlePhotoCapture(string $photo): void
|
|
||||||
{
|
|
||||||
$this->data['photo'] = $photo;
|
|
||||||
\Log::info('WEBCAM: photo-captured event received, length: ' . strlen($photo));
|
|
||||||
}
|
|
||||||
|
|
||||||
// protected function mutateFormDataBeforeCreate(array $data): array
|
|
||||||
// {
|
|
||||||
// \Log::info('WEBCAM: mutateFormDataBeforeCreate called, photo value: ' . substr($data['photo'] ?? 'NULL', 0, 50));
|
|
||||||
|
|
||||||
// if (
|
|
||||||
// !empty($data['photo']) &&
|
|
||||||
// str_starts_with($data['photo'], 'data:image')
|
|
||||||
// ) {
|
|
||||||
// $imageData = explode(',', $data['photo'])[1];
|
|
||||||
// $filename = 'visitor_' . time() . '_' . uniqid() . '.jpg';
|
|
||||||
// $path = 'visitor-photos/' . $filename;
|
|
||||||
// Storage::disk('public')->put($path, base64_decode($imageData));
|
|
||||||
// $data['photo'] = $path;
|
|
||||||
|
|
||||||
// \Log::info('WEBCAM: photo saved to ' . $path);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return $data;
|
|
||||||
// }
|
|
||||||
|
|
||||||
protected function mutateFormDataBeforeCreate(array $data): array
|
|
||||||
{
|
|
||||||
if (
|
|
||||||
!empty($data['photo']) &&
|
|
||||||
str_starts_with($data['photo'], 'data:image')
|
|
||||||
) {
|
|
||||||
try {
|
|
||||||
$imageData = explode(',', $data['photo'])[1];
|
|
||||||
|
|
||||||
$filename = 'visitor_' . time() . '_' . uniqid() . '.jpg';
|
|
||||||
|
|
||||||
$path = 'visitor-photos/' . $filename;
|
|
||||||
|
|
||||||
$decoded = base64_decode($imageData);
|
|
||||||
|
|
||||||
$saved = Storage::disk('public')->put($path, $decoded);
|
|
||||||
|
|
||||||
\Log::info('PHOTO UPLOAD (PUBLIC):', [
|
|
||||||
'filename' => $filename,
|
|
||||||
'path' => $path,
|
|
||||||
'size_bytes' => strlen($decoded),
|
|
||||||
'saved' => $saved ? 'SUCCESS' : 'FAILED',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$data['photo'] = $path;
|
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
\Log::error('PHOTO UPLOAD ERROR: ' . $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function setPhoto(string $photo): void
|
|
||||||
{
|
|
||||||
$this->capturedPhoto = $photo;
|
|
||||||
|
|
||||||
// Change this ↓ to dispatch to parent explicitly
|
|
||||||
$this->dispatch('photo-captured', photo: $photo)->to(\App\Filament\Resources\VisitorEntryResource\Pages\CreateVisitorEntry::class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\VisitorEntryResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\VisitorEntryResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\EditRecord;
|
|
||||||
use Livewire\Attributes\On;
|
|
||||||
use Storage;
|
|
||||||
|
|
||||||
class EditVisitorEntry extends EditRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = VisitorEntryResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Actions\ViewAction::make(),
|
|
||||||
Actions\DeleteAction::make(),
|
|
||||||
Actions\ForceDeleteAction::make(),
|
|
||||||
Actions\RestoreAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
#[On('photo-captured')]
|
|
||||||
public function handlePhotoCapture(string $photo): void
|
|
||||||
{
|
|
||||||
$this->data['photo'] = $photo;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function mutateFormDataBeforeSave(array $data): array
|
|
||||||
{
|
|
||||||
if (
|
|
||||||
!empty($data['photo']) &&
|
|
||||||
str_starts_with($data['photo'], 'data:image')
|
|
||||||
) {
|
|
||||||
// Delete the old photo file if one exists
|
|
||||||
$oldPhoto = $this->record->photo;
|
|
||||||
if ($oldPhoto && Storage::disk('public')->exists($oldPhoto)) {
|
|
||||||
Storage::disk('public')->delete($oldPhoto);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save the new photo
|
|
||||||
$imageData = explode(',', $data['photo'])[1];
|
|
||||||
$filename = 'visitor_' . time() . '_' . uniqid() . '.jpg';
|
|
||||||
$path = 'visitor-photos/' . $filename;
|
|
||||||
Storage::disk('public')->put($path, base64_decode($imageData));
|
|
||||||
|
|
||||||
$data['photo'] = $path;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\VisitorEntryResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\VisitorEntryResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\ListRecords;
|
|
||||||
|
|
||||||
class ListVisitorEntries extends ListRecords
|
|
||||||
{
|
|
||||||
protected static string $resource = VisitorEntryResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Actions\CreateAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\VisitorEntryResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\VisitorEntryResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\ViewRecord;
|
|
||||||
|
|
||||||
class ViewVisitorEntry extends ViewRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = VisitorEntryResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Actions\EditAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -51,18 +51,9 @@ class ChatBot extends Component
|
|||||||
|
|
||||||
// ── Basic mode — Invoice status (scan status) ─────────────────────────────
|
// ── Basic mode — Invoice status (scan status) ─────────────────────────────
|
||||||
public string $invoiceNumber = '';
|
public string $invoiceNumber = '';
|
||||||
public string $invoiceStatusResult = ''; // kept for simple error strings
|
public string $invoiceStatusResult = '';
|
||||||
public bool $hasInvoiceStatusResult = false;
|
public bool $hasInvoiceStatusResult = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Structured result from ChatbotService::getInvoiceData().
|
|
||||||
* Shape: type, message, invoice_number, total, scanned, not_scanned, unscanned_serials[]
|
|
||||||
*/
|
|
||||||
public array $invoiceStatusData = [];
|
|
||||||
|
|
||||||
/** Controls whether all unscanned serials are shown (vs the first 10). */
|
|
||||||
public bool $showAllUnscanned = false;
|
|
||||||
|
|
||||||
// ── Advanced mode ─────────────────────────────────────────────────────────
|
// ── Advanced mode ─────────────────────────────────────────────────────────
|
||||||
public string $advancedQuestion = '';
|
public string $advancedQuestion = '';
|
||||||
public string $advancedResult = '';
|
public string $advancedResult = '';
|
||||||
@@ -111,8 +102,6 @@ class ChatBot extends Component
|
|||||||
$this->hasInvoiceResult = false;
|
$this->hasInvoiceResult = false;
|
||||||
$this->invoiceStatusResult = '';
|
$this->invoiceStatusResult = '';
|
||||||
$this->hasInvoiceStatusResult = false;
|
$this->hasInvoiceStatusResult = false;
|
||||||
$this->invoiceStatusData = [];
|
|
||||||
$this->showAllUnscanned = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Basic mode — Production helpers ──────────────────────────────────────
|
// ── Basic mode — Production helpers ──────────────────────────────────────
|
||||||
@@ -315,14 +304,11 @@ class ChatBot extends Component
|
|||||||
{
|
{
|
||||||
$this->invoiceStatusResult = '';
|
$this->invoiceStatusResult = '';
|
||||||
$this->hasInvoiceStatusResult = false;
|
$this->hasInvoiceStatusResult = false;
|
||||||
$this->invoiceStatusData = [];
|
|
||||||
$this->showAllUnscanned = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks up how many serials within an invoice have been scanned / not scanned.
|
* Looks up how many serials within an invoice have been scanned / not scanned.
|
||||||
* Stores structured data in $invoiceStatusData so the blade can render
|
* Delegates to ChatbotService so the DB query and formatting logic live in one place.
|
||||||
* a "show more" serial-number list without dumping 70+ serials in one blob.
|
|
||||||
*/
|
*/
|
||||||
public function fetchInvoiceStatus(): void
|
public function fetchInvoiceStatus(): void
|
||||||
{
|
{
|
||||||
@@ -330,48 +316,26 @@ class ChatBot extends Component
|
|||||||
|
|
||||||
if (empty($invoiceNumber)) {
|
if (empty($invoiceNumber)) {
|
||||||
$this->invoiceStatusResult = 'Please enter a valid invoice number.';
|
$this->invoiceStatusResult = 'Please enter a valid invoice number.';
|
||||||
$this->invoiceStatusData = [];
|
|
||||||
$this->showAllUnscanned = false;
|
|
||||||
$this->hasInvoiceStatusResult = true;
|
$this->hasInvoiceStatusResult = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/** @var \App\Services\ChatbotService $service */
|
/** @var ChatbotService $service */
|
||||||
$service = app(\App\Services\ChatbotService::class);
|
$service = app(ChatbotService::class);
|
||||||
$data = $service->getInvoiceData($invoiceNumber);
|
$this->invoiceStatusResult = $service->ask("invoice = {$invoiceNumber}");
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::error('ChatBot: invoice status fetch failed', [
|
Log::error('ChatBot: invoice status fetch failed', [
|
||||||
'invoice' => $invoiceNumber,
|
'invoice' => $invoiceNumber,
|
||||||
'error' => $e->getMessage(),
|
'error' => $e->getMessage(),
|
||||||
]);
|
]);
|
||||||
$data = [
|
$this->invoiceStatusResult = "Sorry, I couldn't fetch data for invoice {$invoiceNumber}. "
|
||||||
'type' => 'error',
|
. 'Please try again or contact support.';
|
||||||
'message' => "Sorry, I couldn't fetch data for invoice {$invoiceNumber}. "
|
|
||||||
. 'Please try again or contact support.',
|
|
||||||
'invoice_number' => $invoiceNumber,
|
|
||||||
'total' => 0,
|
|
||||||
'scanned' => 0,
|
|
||||||
'not_scanned' => 0,
|
|
||||||
'unscanned_serials' => [],
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->invoiceStatusData = $data;
|
|
||||||
$this->invoiceStatusResult = $data['message']; // fallback plain-text copy
|
|
||||||
$this->showAllUnscanned = false;
|
|
||||||
$this->hasInvoiceStatusResult = true;
|
$this->hasInvoiceStatusResult = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Toggles the "show all / show less" state for unscanned serial numbers
|
|
||||||
* in the Basic → Invoice Status result card.
|
|
||||||
*/
|
|
||||||
public function toggleShowAllUnscanned(): void
|
|
||||||
{
|
|
||||||
$this->showAllUnscanned = ! $this->showAllUnscanned;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── Advanced mode (Gemini-powered) ────────────────────────────────────────
|
// ── Advanced mode (Gemini-powered) ────────────────────────────────────────
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -465,8 +429,6 @@ class ChatBot extends Component
|
|||||||
$this->invoiceNumber = '';
|
$this->invoiceNumber = '';
|
||||||
$this->invoiceStatusResult = '';
|
$this->invoiceStatusResult = '';
|
||||||
$this->hasInvoiceStatusResult = false;
|
$this->hasInvoiceStatusResult = false;
|
||||||
$this->invoiceStatusData = [];
|
|
||||||
$this->showAllUnscanned = false;
|
|
||||||
|
|
||||||
// Advanced mode
|
// Advanced mode
|
||||||
$this->clearAdvancedChat();
|
$this->clearAdvancedChat();
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Livewire;
|
|
||||||
|
|
||||||
use Livewire\Component;
|
|
||||||
|
|
||||||
class Webcam extends Component
|
|
||||||
{
|
|
||||||
|
|
||||||
public string $capturedPhoto = '';
|
|
||||||
|
|
||||||
// Called from JavaScript when a photo is taken
|
|
||||||
public function setPhoto(string $photo): void
|
|
||||||
{
|
|
||||||
$this->capturedPhoto = $photo;
|
|
||||||
|
|
||||||
// Fires a browser event that the Filament form will listen to
|
|
||||||
$this->dispatch('photo-captured', photo: $photo);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called from JavaScript when user clicks "Retake"
|
|
||||||
public function clearPhoto(): void
|
|
||||||
{
|
|
||||||
$this->capturedPhoto = '';
|
|
||||||
|
|
||||||
$this->dispatch('photo-captured', photo: '');
|
|
||||||
}
|
|
||||||
public function render()
|
|
||||||
{
|
|
||||||
return view('livewire.webcam');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
||||||
|
|
||||||
class EmployeeMaster extends Model
|
|
||||||
{
|
|
||||||
|
|
||||||
use SoftDeletes;
|
|
||||||
|
|
||||||
protected $fillable = [
|
|
||||||
'plant_id',
|
|
||||||
'name',
|
|
||||||
'code',
|
|
||||||
'department',
|
|
||||||
'designation',
|
|
||||||
'email',
|
|
||||||
'mobile_number',
|
|
||||||
'created_at',
|
|
||||||
'updated_at',
|
|
||||||
'created_by',
|
|
||||||
'updated_by',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function plant(): BelongsTo
|
|
||||||
{
|
|
||||||
return $this->belongsTo(Plant::class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
||||||
|
|
||||||
class VisitorEntry extends Model
|
|
||||||
{
|
|
||||||
use SoftDeletes;
|
|
||||||
|
|
||||||
protected $fillable = [
|
|
||||||
'mobile_number',
|
|
||||||
'name',
|
|
||||||
'company',
|
|
||||||
'purpose_of_visit',
|
|
||||||
'type',
|
|
||||||
'in_time',
|
|
||||||
'out_time',
|
|
||||||
'photo',
|
|
||||||
'employee_master_id',
|
|
||||||
'number_of_person'
|
|
||||||
];
|
|
||||||
|
|
||||||
public function employeeMaster(): BelongsTo
|
|
||||||
{
|
|
||||||
return $this->belongsTo(EmployeeMaster::class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -83,87 +83,14 @@ class ChatbotService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks up scan status for an invoice number in invoice_validations.
|
* Looks up scan status for an invoice number in invoice_validations.
|
||||||
* Returns a plain-English string (used by the Advanced / free-text path).
|
|
||||||
* Structured callers should use getInvoiceData() directly.
|
|
||||||
*/
|
*/
|
||||||
private function handleInvoice(string $invoiceNumber, string $_unused = ''): string
|
private function handleInvoice(string $invoiceNumber, string $_unused = ''): string
|
||||||
{
|
{
|
||||||
$data = $this->getInvoiceData($invoiceNumber);
|
// Strip any whitespace within the invoice number itself
|
||||||
|
|
||||||
// For the plain-text path (advanced mode / ChatbotService::ask()),
|
|
||||||
// reassemble a human-readable sentence from the structured data.
|
|
||||||
if (in_array($data['type'], ['invalid', 'error', 'not_found'], true)) {
|
|
||||||
return $data['message'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($data['type'] === 'all_scanned') {
|
|
||||||
$n = $data['total'];
|
|
||||||
$itemWord = $n === 1 ? 'serial number' : 'serial numbers';
|
|
||||||
return "For invoice number {$data['invoice_number']}, all {$n} {$itemWord} "
|
|
||||||
. ($n === 1 ? 'has' : 'have') . ' been scanned. ✅';
|
|
||||||
}
|
|
||||||
|
|
||||||
// partial or none_scanned
|
|
||||||
$total = $data['total'];
|
|
||||||
$scanned = $data['scanned'];
|
|
||||||
$notScan = $data['not_scanned'];
|
|
||||||
$inv = $data['invoice_number'];
|
|
||||||
$itemWord = $total === 1 ? 'serial number' : 'serial numbers';
|
|
||||||
|
|
||||||
if ($scanned === 0) {
|
|
||||||
$msg = "For invoice number {$inv}, there "
|
|
||||||
. ($total === 1 ? 'is' : 'are') . " {$total} {$itemWord} "
|
|
||||||
. 'and none have been scanned.';
|
|
||||||
} else {
|
|
||||||
$msg = "For invoice number {$inv}, there "
|
|
||||||
. ($total === 1 ? 'is' : 'are') . " {$total} {$itemWord} in total. "
|
|
||||||
. "Out of which {$scanned} "
|
|
||||||
. ($scanned === 1 ? 'has' : 'have') . ' been scanned and '
|
|
||||||
. "{$notScan} "
|
|
||||||
. ($notScan === 1 ? 'has' : 'have') . ' not been scanned.';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! empty($data['unscanned_serials'])) {
|
|
||||||
$msg .= ' Unscanned serial numbers are: '
|
|
||||||
. implode(', ', $data['unscanned_serials']) . '.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────────────────
|
|
||||||
// Public structured accessor — used by ChatBot (Basic mode)
|
|
||||||
// ─────────────────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns structured scan-status data for an invoice number.
|
|
||||||
*
|
|
||||||
* Return shape:
|
|
||||||
* [
|
|
||||||
* 'type' => 'all_scanned' | 'partial' | 'none_scanned'
|
|
||||||
* | 'not_found' | 'error' | 'invalid',
|
|
||||||
* 'message' => string, // one-line human summary (no serial list)
|
|
||||||
* 'invoice_number' => string,
|
|
||||||
* 'total' => int,
|
|
||||||
* 'scanned' => int,
|
|
||||||
* 'not_scanned' => int,
|
|
||||||
* 'unscanned_serials' => string[], // full list — may be large
|
|
||||||
* ]
|
|
||||||
*/
|
|
||||||
public function getInvoiceData(string $invoiceNumber): array
|
|
||||||
{
|
|
||||||
$invoiceNumber = preg_replace('/\s+/', '', $invoiceNumber);
|
$invoiceNumber = preg_replace('/\s+/', '', $invoiceNumber);
|
||||||
|
|
||||||
if (empty($invoiceNumber)) {
|
if (empty($invoiceNumber)) {
|
||||||
return [
|
return 'Please provide a valid invoice number. Example: invoice = 3RA0013333';
|
||||||
'type' => 'invalid',
|
|
||||||
'message' => 'Please provide a valid invoice number. Example: invoice = 3RA0013333',
|
|
||||||
'invoice_number' => '',
|
|
||||||
'total' => 0,
|
|
||||||
'scanned' => 0,
|
|
||||||
'not_scanned' => 0,
|
|
||||||
'unscanned_serials' => [],
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -187,88 +114,71 @@ class ChatbotService
|
|||||||
'error' => $e->getMessage(),
|
'error' => $e->getMessage(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return [
|
return "Sorry, I couldn't fetch data for invoice {$invoiceNumber}. "
|
||||||
'type' => 'error',
|
. 'Please try again or contact support if this keeps happening.';
|
||||||
'message' => "Sorry, I couldn't fetch data for invoice {$invoiceNumber}. "
|
|
||||||
. 'Please try again or contact support if this keeps happening.',
|
|
||||||
'invoice_number' => $invoiceNumber,
|
|
||||||
'total' => 0,
|
|
||||||
'scanned' => 0,
|
|
||||||
'not_scanned' => 0,
|
|
||||||
'unscanned_serials' => [],
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return [
|
return "No records found for invoice number {$invoiceNumber}. "
|
||||||
'type' => 'not_found',
|
. 'Please double-check the invoice number and try again.';
|
||||||
'message' => "No records found for invoice number {$invoiceNumber}. "
|
|
||||||
. 'Please double-check the invoice number and try again.',
|
|
||||||
'invoice_number' => $invoiceNumber,
|
|
||||||
'total' => 0,
|
|
||||||
'scanned' => 0,
|
|
||||||
'not_scanned' => 0,
|
|
||||||
'unscanned_serials' => [],
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Aggregate rows ────────────────────────────────────────────────────
|
return $this->formatInvoiceResponse($invoiceNumber, $rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn the raw DB rows into a plain-English summary.
|
||||||
|
*/
|
||||||
|
private function formatInvoiceResponse(string $invoiceNumber, array $rows): string
|
||||||
|
{
|
||||||
$totalScanned = 0;
|
$totalScanned = 0;
|
||||||
$totalNotScanned = 0;
|
$totalNotScanned = 0;
|
||||||
$unscannedSerials = [];
|
$unscannedList = null;
|
||||||
|
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
if ($row->status === 'not scanned') {
|
if ($row->status === 'not scanned') {
|
||||||
$totalNotScanned = (int) $row->total_count;
|
$totalNotScanned = (int) $row->total_count;
|
||||||
if (! empty($row->serial_numbers_not_scanned)) {
|
$unscannedList = $row->serial_numbers_not_scanned;
|
||||||
$unscannedSerials = array_values(
|
|
||||||
array_filter(
|
|
||||||
array_map('trim', explode(',', $row->serial_numbers_not_scanned))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$totalScanned += (int) $row->total_count;
|
$totalScanned += (int) $row->total_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$grandTotal = $totalScanned + $totalNotScanned;
|
$grandTotal = $totalScanned + $totalNotScanned;
|
||||||
|
$itemWord = $grandTotal === 1 ? 'serial number' : 'serial numbers';
|
||||||
|
|
||||||
// ── All scanned ───────────────────────────────────────────────────────
|
// ── All scanned ───────────────────────────────────────────────────────
|
||||||
if ($totalNotScanned === 0) {
|
if ($totalNotScanned === 0) {
|
||||||
$n = $grandTotal;
|
return "For invoice number {$invoiceNumber}, all {$grandTotal} {$itemWord} "
|
||||||
$itemWord = $n === 1 ? 'serial number' : 'serial numbers';
|
. ($grandTotal === 1 ? 'has' : 'have') . ' been scanned. ✅';
|
||||||
return [
|
|
||||||
'type' => 'all_scanned',
|
|
||||||
'message' => "All {$n} {$itemWord} scanned for invoice {$invoiceNumber}. ✅",
|
|
||||||
'invoice_number' => $invoiceNumber,
|
|
||||||
'total' => $grandTotal,
|
|
||||||
'scanned' => $totalScanned,
|
|
||||||
'not_scanned' => 0,
|
|
||||||
'unscanned_serials' => [],
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── None / partial scanned ────────────────────────────────────────────
|
// ── None scanned ──────────────────────────────────────────────────────
|
||||||
$type = $totalScanned === 0 ? 'none_scanned' : 'partial';
|
|
||||||
$itemWord = $grandTotal === 1 ? 'serial number' : 'serial numbers';
|
|
||||||
|
|
||||||
if ($totalScanned === 0) {
|
if ($totalScanned === 0) {
|
||||||
$summary = "Invoice {$invoiceNumber} — {$grandTotal} {$itemWord}, none scanned yet.";
|
$msg = "For invoice number {$invoiceNumber}, there "
|
||||||
} else {
|
. ($grandTotal === 1 ? 'is' : 'are') . " {$grandTotal} {$itemWord} "
|
||||||
$summary = "Invoice {$invoiceNumber} — {$grandTotal} {$itemWord} total: "
|
. 'and none have been scanned.';
|
||||||
. "{$totalScanned} scanned, {$totalNotScanned} not scanned.";
|
|
||||||
|
if ($unscannedList) {
|
||||||
|
$msg .= " Unscanned serial numbers are: {$unscannedList}.";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
// ── Mixed ─────────────────────────────────────────────────────────────
|
||||||
'type' => $type,
|
$msg = "For invoice number {$invoiceNumber}, there "
|
||||||
'message' => $summary,
|
. ($grandTotal === 1 ? 'is' : 'are') . " {$grandTotal} {$itemWord} in total. "
|
||||||
'invoice_number' => $invoiceNumber,
|
. "Out of which {$totalScanned} "
|
||||||
'total' => $grandTotal,
|
. ($totalScanned === 1 ? 'has' : 'have') . ' been scanned and '
|
||||||
'scanned' => $totalScanned,
|
. "{$totalNotScanned} "
|
||||||
'not_scanned' => $totalNotScanned,
|
. ($totalNotScanned === 1 ? 'has' : 'have') . ' not been scanned.';
|
||||||
'unscanned_serials' => $unscannedSerials,
|
|
||||||
];
|
if ($unscannedList) {
|
||||||
|
$msg .= " Unscanned serial numbers are: {$unscannedList}.";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────────────────
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*/
|
|
||||||
public function up(): void
|
|
||||||
{
|
|
||||||
$sql = <<<'SQL'
|
|
||||||
CREATE TABLE employee_masters (
|
|
||||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
|
||||||
|
|
||||||
plant_id BIGINT NOT NULL,
|
|
||||||
name TEXT DEFAULT NULL,
|
|
||||||
code TEXT DEFAULT NULL,
|
|
||||||
department TEXT DEFAULT NULL,
|
|
||||||
designation TEXT DEFAULT NULL,
|
|
||||||
email TEXT DEFAULT NULL,
|
|
||||||
mobile_number TEXT DEFAULT NULL,
|
|
||||||
|
|
||||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
|
||||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
|
||||||
created_by TEXT DEFAULT NULL,
|
|
||||||
updated_by TEXT DEFAULT NULL,
|
|
||||||
deleted_at TIMESTAMP,
|
|
||||||
|
|
||||||
FOREIGN KEY (plant_id) REFERENCES plants (id)
|
|
||||||
);
|
|
||||||
SQL;
|
|
||||||
DB::statement($sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
Schema::dropIfExists('employee_masters');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*/
|
|
||||||
public function up(): void
|
|
||||||
{
|
|
||||||
$sql = <<<'SQL'
|
|
||||||
CREATE TABLE visitor_entries (
|
|
||||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
|
||||||
employee_master_id BIGINT NOT NULL,
|
|
||||||
mobile_number BIGINT NOT NULL,
|
|
||||||
name TEXT DEFAULT NULL,
|
|
||||||
company TEXT DEFAULT NULL,
|
|
||||||
purpose_of_visit TEXT DEFAULT NULL,
|
|
||||||
type TEXT DEFAULT NULL,
|
|
||||||
number_of_person INTEGER DEFAULT NULL,
|
|
||||||
in_time TIMESTAMP DEFAULT NULL,
|
|
||||||
out_time TIMESTAMP DEFAULT NULL,
|
|
||||||
photo TEXT DEFAULT NULL,
|
|
||||||
|
|
||||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
|
||||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
|
||||||
created_by TEXT DEFAULT NULL,
|
|
||||||
updated_by TEXT DEFAULT NULL,
|
|
||||||
deleted_at TIMESTAMP,
|
|
||||||
|
|
||||||
FOREIGN KEY (employee_master_id) REFERENCES employee_masters (id)
|
|
||||||
);
|
|
||||||
SQL;
|
|
||||||
DB::statement($sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
Schema::dropIfExists('visitor_entries');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<div>
|
|
||||||
<x-filament::section>
|
|
||||||
<x-slot name="heading">
|
|
||||||
Visitor Photo
|
|
||||||
</x-slot>
|
|
||||||
|
|
||||||
<livewire:webcam />
|
|
||||||
|
|
||||||
</x-filament::section>
|
|
||||||
</div>
|
|
||||||
@@ -174,7 +174,7 @@
|
|||||||
{{-- ── BASIC MODE ── --}}
|
{{-- ── BASIC MODE ── --}}
|
||||||
{{-- ══════════════════════════════════════════════════════════════════ --}}
|
{{-- ══════════════════════════════════════════════════════════════════ --}}
|
||||||
@if($mode === 'basic')
|
@if($mode === 'basic')
|
||||||
<div style="padding:1rem;display:flex;flex-direction:column;gap:0.875rem;max-height:480px;overflow-y:auto;">
|
<div style="padding:1rem;display:flex;flex-direction:column;gap:0.875rem;">
|
||||||
|
|
||||||
{{-- ── Report Type Selector (dropdown) ──────────────────────────── --}}
|
{{-- ── Report Type Selector (dropdown) ──────────────────────────── --}}
|
||||||
<div style="position:relative;">
|
<div style="position:relative;">
|
||||||
@@ -431,138 +431,25 @@
|
|||||||
|
|
||||||
{{-- Invoice Status Result --}}
|
{{-- Invoice Status Result --}}
|
||||||
@if($hasInvoiceStatusResult)
|
@if($hasInvoiceStatusResult)
|
||||||
|
<div style="background:#111827;border:1px solid {{ str_contains($invoiceStatusResult, '✅') ? '#10b981' : (str_contains($invoiceStatusResult, 'No records') || str_contains($invoiceStatusResult, 'valid') ? '#f59e0b' : '#3b82f6') }};border-radius:0.5rem;padding:0.875rem;display:flex;gap:0.75rem;align-items:flex-start;animation:fadeIn .25s ease;">
|
||||||
@php
|
@if(str_contains($invoiceStatusResult, '✅'))
|
||||||
$sd = $invoiceStatusData;
|
{{-- All scanned — green check --}}
|
||||||
$sdType = $sd['type'] ?? 'error';
|
<svg style="width:1.25rem;height:1.25rem;color:#10b981;flex-shrink:0;margin-top:0.1rem;" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
||||||
$sdTotal = $sd['total'] ?? 0;
|
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
|
||||||
$sdScanned = $sd['scanned'] ?? 0;
|
</svg>
|
||||||
$sdNot = $sd['not_scanned'] ?? 0;
|
@elseif(str_contains($invoiceStatusResult, 'No records') || str_contains($invoiceStatusResult, 'valid') || str_contains($invoiceStatusResult, "couldn't"))
|
||||||
$sdSerials = $sd['unscanned_serials'] ?? [];
|
{{-- Not found / error — warning --}}
|
||||||
$sdCount = count($sdSerials);
|
<svg style="width:1.25rem;height:1.25rem;color:#f59e0b;flex-shrink:0;margin-top:0.1rem;" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
||||||
$sdInv = $sd['invoice_number'] ?? '';
|
<path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z" />
|
||||||
$isGood = $sdType === 'all_scanned';
|
</svg>
|
||||||
$isWarn = in_array($sdType, ['error', 'not_found', 'invalid']);
|
@else
|
||||||
$borderCol = $isGood ? '#10b981' : ($isWarn ? '#f59e0b' : '#3b82f6');
|
{{-- Partial / none scanned — barcode --}}
|
||||||
@endphp
|
<svg style="width:1.25rem;height:1.25rem;color:#3b82f6;flex-shrink:0;margin-top:0.1rem;" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 4.875c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5A1.125 1.125 0 0 1 3.75 9.375v-4.5ZM3.75 14.625c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5a1.125 1.125 0 0 1-1.125-1.125v-4.5ZM13.5 4.875c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5A1.125 1.125 0 0 1 13.5 9.375v-4.5Z" />
|
||||||
<div style="background:#111827;border:1px solid {{ $borderCol }};border-radius:0.5rem;padding:0.875rem;animation:fadeIn .25s ease;">
|
<path stroke-linecap="round" stroke-linejoin="round" d="M6.75 6.75h.75v.75h-.75v-.75ZM6.75 16.5h.75v.75h-.75v-.75ZM16.5 6.75h.75v.75h-.75v-.75ZM13.5 13.5h.75v.75h-.75v-.75ZM13.5 19.5h.75v.75h-.75v-.75ZM19.5 13.5h.75v.75h-.75v-.75ZM19.5 19.5h.75v.75h-.75v-.75ZM16.5 16.5h.75v.75h-.75v-.75Z" />
|
||||||
|
</svg>
|
||||||
{{-- ── Icon + summary row ── --}}
|
|
||||||
<div style="display:flex;gap:0.75rem;align-items:flex-start;">
|
|
||||||
@if($isGood)
|
|
||||||
<svg style="width:1.25rem;height:1.25rem;color:#10b981;flex-shrink:0;margin-top:0.1rem;" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
|
|
||||||
</svg>
|
|
||||||
@elseif($isWarn)
|
|
||||||
<svg style="width:1.25rem;height:1.25rem;color:#f59e0b;flex-shrink:0;margin-top:0.1rem;" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z" />
|
|
||||||
</svg>
|
|
||||||
@else
|
|
||||||
<svg style="width:1.25rem;height:1.25rem;color:#3b82f6;flex-shrink:0;margin-top:0.1rem;" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 4.875c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5A1.125 1.125 0 0 1 3.75 9.375v-4.5ZM3.75 14.625c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5a1.125 1.125 0 0 1-1.125-1.125v-4.5ZM13.5 4.875c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5A1.125 1.125 0 0 1 13.5 9.375v-4.5Z" />
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M6.75 6.75h.75v.75h-.75v-.75ZM6.75 16.5h.75v.75h-.75v-.75ZM16.5 6.75h.75v.75h-.75v-.75ZM13.5 13.5h.75v.75h-.75v-.75ZM13.5 19.5h.75v.75h-.75v-.75ZM19.5 13.5h.75v.75h-.75v-.75ZM19.5 19.5h.75v.75h-.75v-.75ZM16.5 16.5h.75v.75h-.75v-.75Z" />
|
|
||||||
</svg>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
<div style="flex:1;min-width:0;">
|
|
||||||
<p style="font-size:0.8125rem;color:#f9fafb;line-height:1.6;margin:0;">
|
|
||||||
{{ $sd['message'] ?? $invoiceStatusResult }}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
{{-- ── Count pills (only for real invoice data) ── --}}
|
|
||||||
@if($sdTotal > 0)
|
|
||||||
<div style="display:flex;gap:0.375rem;flex-wrap:wrap;margin-top:0.625rem;">
|
|
||||||
<span style="background:#1e3a2f;border:1px solid #10b98155;color:#6ee7b7;font-size:0.68rem;font-weight:700;padding:0.2rem 0.55rem;border-radius:9999px;">
|
|
||||||
Total: {{ $sdTotal }}
|
|
||||||
</span>
|
|
||||||
<span style="background:#1a3350;border:1px solid #3b82f655;color:#93c5fd;font-size:0.68rem;font-weight:700;padding:0.2rem 0.55rem;border-radius:9999px;">
|
|
||||||
✔ Scanned: {{ $sdScanned }}
|
|
||||||
</span>
|
|
||||||
@if($sdNot > 0)
|
|
||||||
<span style="background:#3b1a1a;border:1px solid #ef444455;color:#fca5a5;font-size:0.68rem;font-weight:700;padding:0.2rem 0.55rem;border-radius:9999px;">
|
|
||||||
✘ Not scanned: {{ $sdNot }}
|
|
||||||
</span>
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{-- ── Unscanned serial numbers section ── --}}
|
|
||||||
@if($sdCount > 0)
|
|
||||||
<div style="margin-top:0.875rem;border-top:1px solid #374151;padding-top:0.75rem;">
|
|
||||||
|
|
||||||
<p style="font-size:0.72rem;font-weight:600;color:#9ca3af;margin:0 0 0.5rem;text-transform:uppercase;letter-spacing:.05em;">
|
|
||||||
Unscanned serial numbers
|
|
||||||
<span style="background:#3b1a1a;color:#fca5a5;border-radius:9999px;padding:0.1rem 0.45rem;font-size:0.68rem;margin-left:0.25rem;">
|
|
||||||
{{ $sdCount }}
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
{{-- Serial chips — first 10, or all when expanded --}}
|
|
||||||
@php
|
|
||||||
$visibleSerials = $showAllUnscanned
|
|
||||||
? $sdSerials
|
|
||||||
: array_slice($sdSerials, 0, 10);
|
|
||||||
$hiddenCount = $sdCount - 10;
|
|
||||||
@endphp
|
|
||||||
|
|
||||||
<div style="display:flex;flex-wrap:wrap;gap:0.35rem;
|
|
||||||
@if($showAllUnscanned) max-height:200px;overflow-y:auto;padding-right:2px; @endif">
|
|
||||||
@foreach($visibleSerials as $serial)
|
|
||||||
<span style="
|
|
||||||
display:inline-block;
|
|
||||||
background:#1e293b;
|
|
||||||
border:1px solid #475569;
|
|
||||||
color:#e2e8f0;
|
|
||||||
font-family:monospace;
|
|
||||||
font-size:0.72rem;
|
|
||||||
padding:0.2rem 0.5rem;
|
|
||||||
border-radius:0.3rem;
|
|
||||||
white-space:nowrap;
|
|
||||||
">{{ $serial }}</span>
|
|
||||||
@endforeach
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{-- Show more / Show less button --}}
|
|
||||||
@if($sdCount > 10)
|
|
||||||
<button
|
|
||||||
wire:click="toggleShowAllUnscanned"
|
|
||||||
style="
|
|
||||||
margin-top:0.625rem;
|
|
||||||
background:transparent;
|
|
||||||
border:1px solid #3b82f655;
|
|
||||||
border-radius:0.375rem;
|
|
||||||
color:#60a5fa;
|
|
||||||
font-size:0.75rem;
|
|
||||||
font-weight:600;
|
|
||||||
padding:0.3rem 0.75rem;
|
|
||||||
cursor:pointer;
|
|
||||||
display:flex;
|
|
||||||
align-items:center;
|
|
||||||
gap:0.35rem;
|
|
||||||
transition:background .15s, border-color .15s;
|
|
||||||
"
|
|
||||||
onmouseover="this.style.background='#1e3a5f';this.style.borderColor='#3b82f6';"
|
|
||||||
onmouseout="this.style.background='transparent';this.style.borderColor='#3b82f655';">
|
|
||||||
@if($showAllUnscanned)
|
|
||||||
<svg style="width:0.75rem;height:0.75rem;" fill="none" viewBox="0 0 24 24" stroke-width="2.5" stroke="currentColor">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="m4.5 15.75 7.5-7.5 7.5 7.5" />
|
|
||||||
</svg>
|
|
||||||
Show less
|
|
||||||
@else
|
|
||||||
<svg style="width:0.75rem;height:0.75rem;" fill="none" viewBox="0 0 24 24" stroke-width="2.5" stroke="currentColor">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" />
|
|
||||||
</svg>
|
|
||||||
Show {{ $hiddenCount }} more…
|
|
||||||
@endif
|
|
||||||
</button>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
</div>
|
|
||||||
@endif
|
@endif
|
||||||
|
<p style="font-size:0.8125rem;color:#f9fafb;line-height:1.6;margin:0;white-space:pre-line;">{{ $invoiceStatusResult }}</p>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@@ -732,3 +619,4 @@
|
|||||||
@endif
|
@endif
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,193 +0,0 @@
|
|||||||
<div
|
|
||||||
x-data="{
|
|
||||||
cameraActive: false,
|
|
||||||
captured: false,
|
|
||||||
errorMessage: '',
|
|
||||||
photoData: '',
|
|
||||||
|
|
||||||
async startCamera() {
|
|
||||||
this.errorMessage = '';
|
|
||||||
try {
|
|
||||||
const stream = await navigator.mediaDevices.getUserMedia({
|
|
||||||
video: { width: 640, height: 480, facingMode: 'user' }
|
|
||||||
});
|
|
||||||
this.$refs.video.srcObject = stream;
|
|
||||||
await this.$refs.video.play();
|
|
||||||
this.cameraActive = true;
|
|
||||||
} catch (err) {
|
|
||||||
if (err.name === 'NotAllowedError') {
|
|
||||||
this.errorMessage = 'Camera permission denied. Please allow camera access in your browser and try again.';
|
|
||||||
} else if (err.name === 'NotFoundError') {
|
|
||||||
this.errorMessage = 'No camera found. Please connect a webcam and try again.';
|
|
||||||
} else {
|
|
||||||
this.errorMessage = 'Could not access camera: ' + err.message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
capture() {
|
|
||||||
const canvas = this.$refs.canvas;
|
|
||||||
const video = this.$refs.video;
|
|
||||||
canvas.width = video.videoWidth || 640;
|
|
||||||
canvas.height = video.videoHeight || 480;
|
|
||||||
canvas.getContext('2d').drawImage(video, 0, 0);
|
|
||||||
const photoData = canvas.toDataURL('image/jpeg', 0.85);
|
|
||||||
|
|
||||||
// Stop the camera stream after capture
|
|
||||||
if (video.srcObject) {
|
|
||||||
video.srcObject.getTracks().forEach(track => track.stop());
|
|
||||||
}
|
|
||||||
this.cameraActive = false;
|
|
||||||
this.captured = true;
|
|
||||||
this.photoData = photoData;
|
|
||||||
|
|
||||||
// Send photo data to PHP via Livewire
|
|
||||||
$wire.setPhoto(photoData);
|
|
||||||
},
|
|
||||||
|
|
||||||
retake() {
|
|
||||||
this.captured = false;
|
|
||||||
this.photoData = '';
|
|
||||||
$wire.clearPhoto();
|
|
||||||
this.$nextTick(() => this.startCamera());
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
style="font-family: inherit;"
|
|
||||||
>
|
|
||||||
{{-- ── Error message ── --}}
|
|
||||||
<template x-if="errorMessage">
|
|
||||||
<div style="
|
|
||||||
background: #3b1a1a;
|
|
||||||
border: 1px solid #7f2020;
|
|
||||||
color: #f87171;
|
|
||||||
padding: 10px 14px;
|
|
||||||
border-radius: 8px;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
font-size: 13px;
|
|
||||||
" x-text="errorMessage"></div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
{{-- ── Live video feed (shown while camera is active) ── --}}
|
|
||||||
<div x-show="cameraActive && !captured" style="position: relative;">
|
|
||||||
<video
|
|
||||||
x-ref="video"
|
|
||||||
autoplay
|
|
||||||
playsinline
|
|
||||||
muted
|
|
||||||
style="
|
|
||||||
width: 100%;
|
|
||||||
max-width: 480px;
|
|
||||||
border-radius: 10px;
|
|
||||||
display: block;
|
|
||||||
background: #111;
|
|
||||||
"
|
|
||||||
></video>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{-- ── Captured photo preview (shown after capture) ── --}}
|
|
||||||
<div x-show="captured" style="position: relative;">
|
|
||||||
<img
|
|
||||||
{{-- x-bind:src="$refs.canvas ? $refs.canvas.toDataURL('image/jpeg') : ''" --}}
|
|
||||||
x-bind:src="photoData"
|
|
||||||
style="
|
|
||||||
width: 100%;
|
|
||||||
max-width: 480px;
|
|
||||||
border-radius: 10px;
|
|
||||||
display: block;
|
|
||||||
border: 2px solid #16a34a;
|
|
||||||
"
|
|
||||||
alt="Captured visitor photo"
|
|
||||||
/>
|
|
||||||
<div style="
|
|
||||||
position: absolute;
|
|
||||||
top: 10px; left: 10px;
|
|
||||||
background: #16a34a;
|
|
||||||
color: white;
|
|
||||||
padding: 3px 10px;
|
|
||||||
border-radius: 20px;
|
|
||||||
font-size: 12px;
|
|
||||||
">✓ Photo captured</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{-- ── Placeholder (before camera starts) ── --}}
|
|
||||||
<div
|
|
||||||
x-show="!cameraActive && !captured"
|
|
||||||
style="
|
|
||||||
width: 100%;
|
|
||||||
max-width: 480px;
|
|
||||||
height: 200px;
|
|
||||||
background: #1a1a1a;
|
|
||||||
border: 2px dashed #444;
|
|
||||||
border-radius: 10px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
color: #666;
|
|
||||||
font-size: 14px;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
📷 Camera not started yet
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{-- ── Hidden canvas used for capturing the frame ── --}}
|
|
||||||
<canvas x-ref="canvas" style="display: none;"></canvas>
|
|
||||||
|
|
||||||
{{-- ── Buttons ── --}}
|
|
||||||
<div style="display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap;">
|
|
||||||
|
|
||||||
{{-- Start Camera button --}}
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
x-show="!cameraActive && !captured"
|
|
||||||
x-on:click="startCamera()"
|
|
||||||
style="
|
|
||||||
background: #2563eb;
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
padding: 9px 20px;
|
|
||||||
border-radius: 8px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 14px;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
📷 Start Camera
|
|
||||||
</button>
|
|
||||||
|
|
||||||
{{-- Capture button --}}
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
x-show="cameraActive && !captured"
|
|
||||||
x-on:click="capture()"
|
|
||||||
style="
|
|
||||||
background: #16a34a;
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
padding: 9px 20px;
|
|
||||||
border-radius: 8px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 14px;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
📸 Capture Photo
|
|
||||||
</button>
|
|
||||||
|
|
||||||
{{-- Retake button --}}
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
x-show="captured"
|
|
||||||
x-on:click="retake()"
|
|
||||||
style="
|
|
||||||
background: #b45309;
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
padding: 9px 20px;
|
|
||||||
border-radius: 8px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 14px;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
🔄 Retake Photo
|
|
||||||
</button>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
Reference in New Issue
Block a user