Fix counter console 404 when routes are cached.
Deploy Ladill Queue / deploy (push) Successful in 47s
Deploy Ladill Queue / deploy (push) Successful in 47s
Route model binding fell back to numeric id after route:cache; models now resolve by uuid so Care and Frontdesk counter consoles work in production. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Concerns;
|
||||
|
||||
trait UsesUuidRouteKey
|
||||
{
|
||||
public function getRouteKeyName(): string
|
||||
{
|
||||
return 'uuid';
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToOwner;
|
||||
use App\Models\Concerns\UsesUuidRouteKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
@@ -12,7 +13,7 @@ use Illuminate\Support\Str;
|
||||
|
||||
class Counter extends Model
|
||||
{
|
||||
use BelongsToOwner, SoftDeletes;
|
||||
use BelongsToOwner, SoftDeletes, UsesUuidRouteKey;
|
||||
|
||||
protected $table = 'queue_counters';
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToOwner;
|
||||
use App\Models\Concerns\UsesUuidRouteKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
@@ -10,7 +11,7 @@ use Illuminate\Support\Str;
|
||||
|
||||
class Device extends Model
|
||||
{
|
||||
use BelongsToOwner, SoftDeletes;
|
||||
use BelongsToOwner, SoftDeletes, UsesUuidRouteKey;
|
||||
|
||||
protected $table = 'queue_devices';
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToOwner;
|
||||
use App\Models\Concerns\UsesUuidRouteKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
@@ -10,7 +11,7 @@ use Illuminate\Support\Str;
|
||||
|
||||
class DisplayScreen extends Model
|
||||
{
|
||||
use BelongsToOwner, SoftDeletes;
|
||||
use BelongsToOwner, SoftDeletes, UsesUuidRouteKey;
|
||||
|
||||
protected $table = 'queue_display_screens';
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToOwner;
|
||||
use App\Models\Concerns\UsesUuidRouteKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
@@ -10,7 +11,7 @@ use Illuminate\Support\Str;
|
||||
|
||||
class QueueAppointment extends Model
|
||||
{
|
||||
use BelongsToOwner, SoftDeletes;
|
||||
use BelongsToOwner, SoftDeletes, UsesUuidRouteKey;
|
||||
|
||||
protected $table = 'queue_appointments';
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToOwner;
|
||||
use App\Models\Concerns\UsesUuidRouteKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
@@ -12,7 +13,7 @@ use Illuminate\Support\Str;
|
||||
|
||||
class ServiceQueue extends Model
|
||||
{
|
||||
use BelongsToOwner, SoftDeletes;
|
||||
use BelongsToOwner, SoftDeletes, UsesUuidRouteKey;
|
||||
|
||||
protected $table = 'queue_service_queues';
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToOwner;
|
||||
use App\Models\Concerns\UsesUuidRouteKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
@@ -11,7 +12,7 @@ use Illuminate\Support\Str;
|
||||
|
||||
class Ticket extends Model
|
||||
{
|
||||
use BelongsToOwner, SoftDeletes;
|
||||
use BelongsToOwner, SoftDeletes, UsesUuidRouteKey;
|
||||
|
||||
protected $table = 'queue_tickets';
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToOwner;
|
||||
use App\Models\Concerns\UsesUuidRouteKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
@@ -11,7 +12,7 @@ use Illuminate\Support\Str;
|
||||
|
||||
class Workflow extends Model
|
||||
{
|
||||
use BelongsToOwner, SoftDeletes;
|
||||
use BelongsToOwner, SoftDeletes, UsesUuidRouteKey;
|
||||
|
||||
protected $table = 'queue_workflows';
|
||||
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Branch;
|
||||
use App\Models\Counter;
|
||||
use App\Models\Organization;
|
||||
use App\Models\ServiceQueue;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -20,6 +23,17 @@ class CareIntegrationTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
protected function provisionCareOrg(string $owner = 'care-owner-uuid'): Organization
|
||||
{
|
||||
$this->postJson('/api/v1/integrations/provision', [
|
||||
'owner' => $owner,
|
||||
'organization_name' => 'Care Clinic',
|
||||
'branch_name' => 'Main',
|
||||
], $this->careHeaders($owner))->assertSuccessful();
|
||||
|
||||
return Organization::owned($owner)->firstOrFail();
|
||||
}
|
||||
|
||||
public function test_provision_enables_care_integration(): void
|
||||
{
|
||||
$owner = 'care-owner-uuid';
|
||||
@@ -41,12 +55,46 @@ class CareIntegrationTest extends TestCase
|
||||
$owner = 'care-owner-uuid';
|
||||
$headers = $this->careHeaders($owner);
|
||||
|
||||
$this->postJson('/api/v1/integrations/provision', [
|
||||
'owner' => $owner,
|
||||
'organization_name' => 'Care Clinic',
|
||||
], $headers)->assertSuccessful();
|
||||
$this->provisionCareOrg($owner);
|
||||
|
||||
$this->getJson('/api/v1/counters?owner='.$owner, $headers)
|
||||
->assertOk();
|
||||
}
|
||||
|
||||
public function test_counter_console_resolves_by_uuid(): void
|
||||
{
|
||||
$owner = 'care-owner-uuid';
|
||||
$headers = $this->careHeaders($owner);
|
||||
$organization = $this->provisionCareOrg($owner);
|
||||
$branch = Branch::owned($owner)->where('organization_id', $organization->id)->firstOrFail();
|
||||
$queue = ServiceQueue::create([
|
||||
'owner_ref' => $owner,
|
||||
'organization_id' => $organization->id,
|
||||
'branch_id' => $branch->id,
|
||||
'name' => 'Morning Shift',
|
||||
'prefix' => 'A',
|
||||
'strategy' => 'fifo',
|
||||
'is_active' => true,
|
||||
]);
|
||||
$counter = Counter::create([
|
||||
'owner_ref' => $owner,
|
||||
'organization_id' => $organization->id,
|
||||
'branch_id' => $branch->id,
|
||||
'name' => 'Counter 1',
|
||||
'code' => 'C001',
|
||||
'status' => 'available',
|
||||
'is_active' => true,
|
||||
]);
|
||||
$counter->serviceQueues()->sync([$queue->id]);
|
||||
|
||||
$this->getJson('/api/v1/counters/'.$counter->uuid.'/console?owner='.$owner, $headers)
|
||||
->assertOk()
|
||||
->assertJsonPath('data.counter.uuid', $counter->uuid);
|
||||
}
|
||||
|
||||
public function test_queue_models_use_uuid_route_key(): void
|
||||
{
|
||||
$this->assertSame('uuid', (new Counter)->getRouteKeyName());
|
||||
$this->assertSame('uuid', (new ServiceQueue)->getRouteKeyName());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user