Add employee presence with kiosk sign-in, QR badges, and mobile step-out.
Deploy Ladill Frontdesk / deploy (push) Failing after 26s
Deploy Ladill Frontdesk / deploy (push) Failing after 26s
Enables staff roster, PIN/code kiosk flow, attendance reports, evacuation staff roll call, webhooks, branch mismatch warnings, and a linked-user My presence portal. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToOwner;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Employee extends Model
|
||||
{
|
||||
use BelongsToOwner, SoftDeletes;
|
||||
|
||||
protected $table = 'frontdesk_employees';
|
||||
|
||||
protected $fillable = [
|
||||
'owner_ref', 'organization_id', 'branch_id', 'employee_code', 'qr_token', 'full_name',
|
||||
'department', 'email', 'phone', 'pin_hash', 'host_id', 'user_ref', 'active',
|
||||
];
|
||||
|
||||
protected $hidden = ['pin_hash'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return ['active' => 'boolean'];
|
||||
}
|
||||
|
||||
public function organization(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Organization::class, 'organization_id');
|
||||
}
|
||||
|
||||
public function branch(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Branch::class, 'branch_id');
|
||||
}
|
||||
|
||||
public function host(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Host::class, 'host_id');
|
||||
}
|
||||
|
||||
public function presence(): HasOne
|
||||
{
|
||||
return $this->hasOne(EmployeePresence::class, 'employee_id');
|
||||
}
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (Employee $employee) {
|
||||
if (! $employee->qr_token) {
|
||||
$employee->qr_token = Str::random(32);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static function findByQrLookup(string $lookup, int $organizationId): ?self
|
||||
{
|
||||
$token = self::parseQrLookup($lookup);
|
||||
|
||||
if ($token === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return self::query()
|
||||
->where('organization_id', $organizationId)
|
||||
->where('qr_token', $token)
|
||||
->where('active', true)
|
||||
->first();
|
||||
}
|
||||
|
||||
public static function parseQrLookup(string $lookup): ?string
|
||||
{
|
||||
$lookup = trim($lookup);
|
||||
|
||||
if ($lookup === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (preg_match('#/eq/([A-Za-z0-9]+)#', $lookup, $matches)) {
|
||||
return $matches[1];
|
||||
}
|
||||
|
||||
if (preg_match('/^[A-Za-z0-9]{16,64}$/', $lookup)) {
|
||||
return $lookup;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user