Files
ladill-pos/app/Models/PosSaleLine.php
T
isaaccladandClaude Opus 4.8 50b170b0af
Deploy Ladill POS / deploy (push) Successful in 35s
Restaurant mode Phase 2: menu depth — categories, stations, modifiers, courses
Builds on Phase 1 with the menu structure restaurants need:
- Menu setup page (restaurant mode): categories, kitchen stations, and modifier
  groups with options (price deltas).
- Products gain category, kitchen station, default course, and attached modifier
  groups (managed on the product form).
- Ordering: the ticket groups the catalog by category and, when a product has
  modifier groups, opens a picker (respects min/max select) for options + notes +
  course before adding. Effective price = base + modifier deltas (resolved
  server-side; client prices are never trusted).
- Fire-by-course: send the whole tab or just one course to the kitchen.
- KDS: filter by station; each item shows its station, course, modifiers and notes.

Schema additive (pos_categories, pos_stations, pos_modifier_groups, pos_modifiers,
product↔group pivot, pos_sale_line_modifiers; category/station/course columns on
products and lines). PosRestaurantTest covers modifiers, course and station routing;
suite green (11 passed).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 19:58:57 +00:00

75 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',
'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');
}
}