Skip to main content

Overview

Worker controllers handle day-to-day operations for technicians and workers. All routes require authentication and the role:worker,admin,developer middleware.

Orders

Manage service orders and repair requests.

List Orders

GET /worker/orders
route
Display paginated list of orders with search functionality.
Middleware: auth, role:worker,admin,developer Route Name: worker.orders Query Parameters:
Search by order ID, technician name, customer name, equipment brand, or equipment model
Response:
  • Returns view with orders (paginated, 18 per page)
  • Includes customers, equipments, company technicians
  • AI diagnostics information (plan, limits, usage)
Controller: App\Http\Controllers\Worker\OrderController@index Source: routes/web.php:29

Create Order

POST /worker/orders
route
Create a new service order with optional AI diagnosis.
Middleware: auth, role:worker,admin,developer Route Name: worker.orders.store Request Parameters:
customer_id
integer
required
ID of the customer (must exist in customers table)
equipment_id
integer
required
ID of the equipment (must exist in equipments table)
technician
string
Name of assigned technician (max 255 characters)
technician_user_id
integer
User ID of assigned technician (must exist in users table)
request_ai_diagnosis
boolean
Whether to request AI-powered diagnosis
symptoms
string
Description of equipment symptoms (5-600 characters, required if request_ai_diagnosis is true)
status
string
Order status (pending, in_progress, waiting_parts, completed, cancelled, delivered)
estimated_cost
number
Estimated repair cost (minimum 0)
Response:
  • Redirects back with success message
  • May include AI warning if diagnosis quota exceeded
Validation: StoreOrderRequest Controller: App\Http\Controllers\Worker\OrderController@store Source: routes/web.php:30

Update Order Status

PATCH /worker/orders/{order}/status
route
Update the status of an existing order.
Middleware: auth, role:worker,admin,developer Route Name: worker.orders.status URL Parameters:
order
integer
required
Order ID
Request Parameters:
status
string
required
New order status (pending, in_progress, waiting_parts, completed, cancelled, delivered)
Response:
  • Redirects back with success message
Authorization: Order must belong to user’s company (except developers) Validation: UpdateOrderStatusRequest Controller: App\Http\Controllers\Worker\OrderController@updateStatus Source: routes/web.php:31

AI Diagnosis

POST /worker/orders/diagnose
route
Request AI diagnosis for equipment (currently disabled - use request_ai_diagnosis flag when creating order).
Middleware: auth, role:worker,admin,developer Route Name: worker.orders.diagnose Request Parameters:
equipment_id
integer
required
ID of equipment to diagnose
symptoms
string
required
Equipment symptoms (5-600 characters)
Response:
  • Returns JSON error (422) indicating direct diagnosis is disabled
  • Users should use “request_ai_diagnosis” flag when creating orders instead
Controller: App\Http\Controllers\Worker\OrderController@diagnose Source: routes/web.php:32

Customers

Manage customer records.

List Customers

GET /worker/customers
route
Display paginated list of customers.
Middleware: auth, role:worker,admin,developer Route Name: worker.customers Query Parameters:
search
string
Search by customer name, email, or phone
Response:
  • Returns view with customers (paginated, 20 per page)
  • Filtered by company (except for developers)
Controller: App\Http\Controllers\Worker\CustomerController@index Source: routes/web.php:34

Create Customer

POST /worker/customers
route
Register a new customer.
Middleware: auth, role:worker,admin,developer Route Name: worker.customers.store Request Parameters:
name
string
required
Customer full name (max 255 characters)
email
string
required
Customer email address (max 255 characters)
phone
string
Customer phone number (max 50 characters)
address
string
Customer address (max 255 characters)
Response:
  • Redirects back with success message
  • Customer is automatically assigned to user’s company
Validation: StoreCustomerRequest Controller: App\Http\Controllers\Worker\CustomerController@store Source: routes/web.php:35

Equipment

Manage customer equipment records.

List Equipment

GET /worker/equipments
route
Display paginated list of equipment.
Middleware: auth, role:worker,admin,developer Route Name: worker.equipments Query Parameters:
search
string
Search by brand, model, type, or customer name
Response:
  • Returns view with equipment (paginated, 18 per page)
  • Includes associated customers
  • Filtered by company (except for developers)
Controller: App\Http\Controllers\Worker\EquipmentController@index Source: routes/web.php:37

Create Equipment

POST /worker/equipments
route
Register new equipment for a customer.
Middleware: auth, role:worker,admin,developer Route Name: worker.equipments.store Request Parameters:
customer_id
integer
required
Customer who owns the equipment (must exist and belong to user’s company)
type
string
required
Equipment type (e.g., “Refrigerator”, “Washing Machine”) - max 100 characters
brand
string
required
Equipment brand (max 100 characters)
model
string
Equipment model number (max 150 characters)
serial_number
string
Equipment serial number (max 150 characters)
Response:
  • Redirects back with success message
  • Equipment is automatically assigned to customer’s company
Authorization: Customer must belong to user’s company Validation: StoreEquipmentRequest Controller: App\Http\Controllers\Worker\EquipmentController@store Source: routes/web.php:38

Inventory

Manage inventory items and stock levels. Requires module_access:inventory middleware.

List Inventory Items

GET /worker/inventory
route
Display inventory items with stock movements and alerts.
Middleware: auth, role:worker,admin,developer, module_access:inventory Route Name: worker.inventory Query Parameters:
search
string
Search by item name or internal code
Response:
  • Returns view with inventory items (paginated, 20 per page)
  • Recent stock movements (last 12)
  • Low stock items and notifications
  • Filtered by company
Controller: App\Http\Controllers\Worker\InventoryController@index Source: routes/web.php:42-44

Create Inventory Item

POST /worker/inventory
route
Add a new item to inventory.
Middleware: auth, role:worker,admin,developer, module_access:inventory Route Name: worker.inventory.store Request Parameters:
name
string
required
Item name (max 180 characters)
internal_code
string
required
Unique internal code (max 120 characters, unique per company)
quantity
integer
required
Initial stock quantity (0-1,000,000)
low_stock_threshold
integer
Alert threshold for low stock (0-1,000,000)
is_sale_enabled
boolean
Whether item can be sold
sale_price
number
Sale price (required if is_sale_enabled is true, max 99,999,999.99)
Response:
  • Redirects back with success message
  • Item is assigned to user’s company
Authorization: User must have inventory module access Validation: StoreInventoryItemRequest Controller: App\Http\Controllers\Worker\InventoryController@store Source: routes/web.php:45-47

Adjust Stock

PATCH /worker/inventory/{item}/stock
route
Add or remove stock for an inventory item.
Middleware: auth, role:worker,admin,developer, module_access:inventory Route Name: worker.inventory.stock URL Parameters:
item
integer
required
Inventory item ID
Request Parameters:
movement_type
string
required
Type of stock movement: “addition” or “removal”
quantity
integer
required
Quantity to add or remove (1-1,000,000)
notes
string
Notes about the movement (max 255 characters)
Response:
  • Redirects back with success message
  • Creates inventory movement record
Authorization: Item must belong to user’s company Validation: AdjustInventoryStockRequest Controller: App\Http\Controllers\Worker\InventoryController@adjustStock Source: routes/web.php:48-50

Delete Inventory Item

DELETE /worker/inventory/{item}
route
Remove an item from inventory.
Middleware: auth, role:worker,admin,developer, module_access:inventory Route Name: worker.inventory.destroy URL Parameters:
item
integer
required
Inventory item ID
Response:
  • Redirects back with success message
Authorization: Item must belong to user’s company Controller: App\Http\Controllers\Worker\InventoryController@destroy Source: routes/web.php:51-53

Billing

Generate invoices and quotes. Requires module_access:billing middleware.

List Billing Documents

GET /worker/billing
route
Display list of billing documents (invoices and quotes).
Middleware: auth, role:worker,admin,developer, module_access:billing Route Name: worker.billing Response:
  • Returns view with billing documents (paginated, 20 per page)
  • Includes customers and inventory items for document creation
  • Company information
  • Available order statuses
Controller: App\Http\Controllers\Worker\BillingController@index Source: routes/web.php:54-56

Create Billing Document

POST /worker/billing
route
Generate a new invoice or quote.
Middleware: auth, role:worker,admin,developer, module_access:billing Route Name: worker.billing.store Request Parameters:
document_type
string
required
Type of document: “quote” or “invoice”
source
string
required
Document source: “repair”, “sale”, or “mixed”
customer_mode
string
required
Customer type: “registered” or “walk_in”
customer_id
integer
Registered customer ID (required if customer_mode is “registered”)
walk_in_name
string
Walk-in customer name (required if customer_mode is “walk_in”, max 180 characters)
tax_mode
string
required
Tax handling: “included” or “excluded”
notes
string
Document notes (max 2000 characters)
items
array
required
Array of line items (minimum 1 item)
items[].item_kind
string
required
Item type: “service” or “product”
items[].description
string
required
Item description (max 255 characters)
items[].quantity
number
required
Item quantity (0.01-999,999)
items[].unit_price
number
required
Price per unit (0-99,999,999.99)
items[].inventory_item_id
integer
Link to inventory item
items[].order_id
integer
Link to service order
Response:
  • Redirects to document detail page
  • Success message
Authorization: Customer must belong to user’s company (if registered) Validation: StoreBillingDocumentRequest Controller: App\Http\Controllers\Worker\BillingController@store Source: routes/web.php:57-59

View Billing Document

GET /worker/billing/{document}
route
Display full details of a billing document.
Middleware: auth, role:worker,admin,developer, module_access:billing Route Name: worker.billing.show URL Parameters:
document
integer
required
Billing document ID
Response:
  • Returns view with complete document details
  • Includes all line items with inventory and order links
  • Customer and company information
Authorization: Document must belong to user’s company Controller: App\Http\Controllers\Worker\BillingController@show Source: routes/web.php:63-65

Download PDF

GET /worker/billing/{document}/pdf
route
Download billing document as PDF.
Middleware: auth, role:worker,admin,developer, module_access:billing Route Name: worker.billing.pdf URL Parameters:
document
integer
required
Billing document ID
Response:
  • Downloads PDF file named with document number
  • A4 paper size
Authorization: Document must belong to user’s company Controller: App\Http\Controllers\Worker\BillingController@pdf Source: routes/web.php:66-68

Get Customer Services

GET /worker/billing/customers/{customer}/services
route
Retrieve all service orders for a customer (JSON endpoint).
Middleware: auth, role:worker,admin,developer, module_access:billing Route Name: worker.billing.customer-services URL Parameters:
customer
integer
required
Customer ID
Response:
{
  "customer": {
    "id": 1,
    "name": "John Doe",
    "email": "john@example.com"
  },
  "orders": [
    {
      "id": 123,
      "description": "Refrigerator repair",
      "estimated_cost": 150.00,
      "status": "completed",
      "status_label": "Completado",
      "equipment": "Samsung RF28"
    }
  ]
}
Authorization: Customer must belong to user’s company Controller: App\Http\Controllers\Worker\BillingController@customerServices Source: routes/web.php:60-62

Usage Examples

Creating an Order with AI Diagnosis

<form method="POST" action="{{ route('worker.orders.store') }}">
    @csrf
    <input type="hidden" name="customer_id" value="1">
    <input type="hidden" name="equipment_id" value="5">
    <input type="text" name="technician" value="John Tech">
    <textarea name="symptoms">Refrigerator not cooling, compressor makes noise</textarea>
    <input type="checkbox" name="request_ai_diagnosis" value="1" checked>
    <input type="number" name="estimated_cost" value="150">
    <select name="status">
        <option value="pending">Pending</option>
        <option value="in_progress">In Progress</option>
    </select>
    <button type="submit">Create Order</button>
</form>

Creating a Billing Document

<form method="POST" action="{{ route('worker.billing.store') }}">
    @csrf
    <select name="document_type">
        <option value="invoice">Invoice</option>
        <option value="quote">Quote</option>
    </select>
    <input type="hidden" name="source" value="repair">
    <input type="hidden" name="customer_mode" value="registered">
    <input type="hidden" name="customer_id" value="1">
    <select name="tax_mode">
        <option value="included">Tax Included</option>
        <option value="excluded">Tax Excluded</option>
    </select>
    
    <!-- Line Items -->
    <input type="hidden" name="items[0][item_kind]" value="service">
    <input type="text" name="items[0][description]" value="Refrigerator Repair">
    <input type="number" name="items[0][quantity]" value="1">
    <input type="number" name="items[0][unit_price]" value="150.00">
    <input type="hidden" name="items[0][order_id]" value="123">
    
    <button type="submit">Generate Document</button>
</form>

Adjusting Inventory Stock

<form method="POST" action="{{ route('worker.inventory.stock', $item) }}">
    @csrf
    @method('PATCH')
    <select name="movement_type">
        <option value="addition">Add Stock</option>
        <option value="removal">Remove Stock</option>
    </select>
    <input type="number" name="quantity" value="10">
    <input type="text" name="notes" placeholder="Reason for adjustment">
    <button type="submit">Update Stock</button>
</form>

Build docs developers (and LLMs) love