Skip to main content
Common Notes
  • Most endpoints require authentication.
  • Access is controlled by policies (viewAny, view, create, update, archive, restore, delete).

Get All Companies

GET /api/companies Returns a paginated list of companies, with optional search by label. Authorization
  • Policy: viewAny on Company
Query Params Response Shape The API returns:
  • data: array of companies (simplified fields)
  • pagination: only per_page and page
Each company may include company_image if available:
  • id
  • file_name
  • url
Response
✅ 200 OK

Create Company

POST /api/companies Creates a new company. Optionally accepts an uploaded image (company_image) and stores it under public/files. Authorization
  • Policy: create on Company
Content-Type This endpoint supports file upload, so use: Body (Validation Rules) Example (multipart)
  • label: Acme Academy
  • description: Training company
  • currency: TND
  • company_image: (file upload)
Response
✅ 200 OK
Notes If company_image is uploaded:
  • A File record is created
  • The file is stored under public/files
  • The company is updated with company_image_id

Get Company By ID

GET /api/companies/{id} Returns a single company (simplified fields) with optional company_image. Authorization
  • Policy: view on Company
Path Params Response
✅ 200 OK

Update Company

POST /api/companies/ Updates company fields and optionally replaces company_image. Authorization
  • Policy: update on Company
Content-Type Body (Validation Rules) Image Replacement Behavior f a new company_image is uploaded:
  1. Deletes the old physical file from public/files/ (if exists)
  2. Deletes the old File record
  3. Creates a new File record
  4. Stores the new file
  5. Updates company_image_id
Response
✅ 200 OK

Archive Company

POST /api/companies/{id}/archive Archives a company. Authorization
  • Policy: archive on Company

✅ 200 OK

Unarchive (Restore) Company

POST /api/companies/{id}/unarchive Restores an archived company. Authorization
  • Policy: restore on Company
Response
✅ 200 OK

Delete Company

DELETE /api/companies/{id} Soft-deletes a company (uses Eloquent delete()). Authorization
  • Policy: delete on Company
Response
✅ 200 OK