Initial Ladill Queue release — enterprise QMS standalone app.
Deploy Ladill Queue / deploy (push) Successful in 56s
Deploy Ladill Queue / deploy (push) Successful in 56s
Phases 1–6: tickets, counters, displays, appointments, workflows, rules, analytics, reports, feedback, admin, device API, and Gitea deploy workflow for queue.ladill.com. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Qms;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Qms\Concerns\ScopesToAccount;
|
||||
use App\Models\QueueRule;
|
||||
use App\Models\ServiceQueue;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class QueueRuleController extends Controller
|
||||
{
|
||||
use ScopesToAccount;
|
||||
|
||||
public function index(Request $request, ServiceQueue $serviceQueue): View
|
||||
{
|
||||
$this->authorizeAbility($request, 'rules.view');
|
||||
$this->authorizeOwner($request, $serviceQueue);
|
||||
|
||||
$rules = QueueRule::owned($this->ownerRef($request))
|
||||
->where('service_queue_id', $serviceQueue->id)
|
||||
->orderBy('sort_order')
|
||||
->get();
|
||||
|
||||
return view('qms.rules.index', [
|
||||
'queue' => $serviceQueue,
|
||||
'rules' => $rules,
|
||||
'ruleTypes' => config('qms.rule_types'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request, ServiceQueue $serviceQueue): RedirectResponse
|
||||
{
|
||||
$this->authorizeAbility($request, 'rules.manage');
|
||||
$this->authorizeOwner($request, $serviceQueue);
|
||||
|
||||
$validated = $request->validate([
|
||||
'rule_type' => ['required', 'string', 'in:'.implode(',', array_keys(config('qms.rule_types')))],
|
||||
'waiting_threshold' => ['nullable', 'integer', 'min:1'],
|
||||
'overflow_queue_id' => ['nullable', 'exists:queue_service_queues,id'],
|
||||
'priority' => ['nullable', 'string', 'in:'.implode(',', array_keys(config('qms.ticket_priorities')))],
|
||||
'source' => ['nullable', 'string'],
|
||||
]);
|
||||
|
||||
$conditions = [];
|
||||
$actions = [];
|
||||
|
||||
if ($validated['rule_type'] === 'overflow') {
|
||||
$conditions['waiting_threshold'] = (int) ($validated['waiting_threshold'] ?? 10);
|
||||
$actions['overflow_queue_id'] = $validated['overflow_queue_id'] ?? null;
|
||||
} elseif ($validated['rule_type'] === 'priority_boost') {
|
||||
$conditions['source'] = $validated['source'] ?? null;
|
||||
$actions['priority'] = $validated['priority'] ?? 'vip';
|
||||
}
|
||||
|
||||
QueueRule::create([
|
||||
'owner_ref' => $this->ownerRef($request),
|
||||
'service_queue_id' => $serviceQueue->id,
|
||||
'rule_type' => $validated['rule_type'],
|
||||
'conditions' => $conditions,
|
||||
'actions' => $actions,
|
||||
'sort_order' => QueueRule::where('service_queue_id', $serviceQueue->id)->max('sort_order') + 1,
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
return back()->with('success', 'Rule added.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request, ServiceQueue $serviceQueue, QueueRule $rule): RedirectResponse
|
||||
{
|
||||
$this->authorizeAbility($request, 'rules.manage');
|
||||
$this->authorizeOwner($request, $serviceQueue);
|
||||
abort_unless($rule->service_queue_id === $serviceQueue->id, 404);
|
||||
|
||||
$rule->delete();
|
||||
|
||||
return back()->with('success', 'Rule removed.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user