Files
ladill-pos/app/Models/PosSaleLine.php
T
isaaccladandClaude Opus 4.8 d4f4821d96
Deploy Ladill POS / deploy (push) Successful in 23s
Restaurant mode Phase 3: table-QR self-ordering into the kitchen
The "links" slice — a guest scans a table's QR, browses the menu (with
modifiers), and submits an order that lands on that table's open tab and fires
straight to the Kitchen Display.

- Public, auth-free flow scoped by an unguessable table short_code:
  GET /t/{code} (menu + client cart), POST /t/{code}/order (throttled),
  GET /t/{code}/done. Orders open/append the table's dine-in tab, add lines as
  source=guest, and send to the kitchen.
- Staff print a per-table QR (Settings → table → QR; renders client-side to the
  public menu URL). short_code is generated lazily.
- Guest lines are badged on the ticket and the KDS so staff can tell them apart;
  staff still settle the tab as usual (cash / Ladill Pay).
- Extracted PosSaleService::buildProductLine as the single product+modifier
  price resolver, now shared by staff and guest ordering (client prices never
  trusted).

Schema additive: pos_tables.short_code, pos_sale_lines.source. New
PosRestaurantTest covers the guest order firing to the kitchen; suite green (12).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 20:13:28 +00:00

76 lines
1.8 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class PosSaleLine extends Model
{
public const KITCHEN_NEW = 'new';
public const KITCHEN_QUEUED = 'queued';
public const KITCHEN_PREPARING = 'preparing';
public const KITCHEN_READY = 'ready';
public const KITCHEN_SERVED = 'served';
/** States the KDS bump button cycles through, in order. */
public const KITCHEN_FLOW = [self::KITCHEN_QUEUED, self::KITCHEN_PREPARING, self::KITCHEN_READY, self::KITCHEN_SERVED];
/** Ordered courses for fire-by-course (key => label). */
public const COURSES = [
'starter' => 'Starter',
'main' => 'Main',
'dessert' => 'Dessert',
'drink' => 'Drink',
];
protected $fillable = [
'pos_sale_id',
'product_id',
'station_id',
'name',
'unit_price_minor',
'quantity',
'line_total_minor',
'position',
'kitchen_state',
'source',
'notes',
'course',
];
protected function casts(): array
{
return [
'unit_price_minor' => 'integer',
'quantity' => 'integer',
'line_total_minor' => 'integer',
'position' => 'integer',
];
}
public function sale(): BelongsTo
{
return $this->belongsTo(PosSale::class, 'pos_sale_id');
}
public function product(): BelongsTo
{
return $this->belongsTo(PosProduct::class, 'product_id');
}
public function station(): BelongsTo
{
return $this->belongsTo(PosStation::class, 'station_id');
}
public function modifiers(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(PosSaleLineModifier::class, 'pos_sale_line_id');
}
}