- 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:
viewAnyonCompany
Response Shape
The API returns:
data: array of companies (simplified fields)pagination: onlyper_pageandpage
company_image if available:
idfile_nameurl
- 200
- 500
✅ 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:
createonCompany
Body (Validation Rules)
Example (multipart)
-
label:
Acme Academy -
description:
Training company -
currency:
TND - company_image: (file upload)
- 200
- 422
- 500
✅ 200 OK
company_image is uploaded:
-
A
Filerecord 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:
viewonCompany
Response
- 200
- 404
✅ 200 OK
Update Company
POST /api/companies/ Updates company fields and optionally replacescompany_image.
Authorization
- Policy:
updateonCompany
Body (Validation Rules)
Image Replacement Behavior
f a new
company_image is uploaded:
-
Deletes the old physical file from
public/files/(if exists) -
Deletes the old
Filerecord -
Creates a new
Filerecord - Stores the new file
-
Updates
company_image_id
- 200
- 422
- 500
✅ 200 OK
Archive Company
POST /api/companies/{id}/archive
Archives a company.
Authorization
- Policy:
archiveonCompany
- 200
- 500
✅ 200 OK
Unarchive (Restore) Company
POST /api/companies/{id}/unarchive
Restores an archived company.
Authorization
- Policy:
restoreonCompany
- 200
- 500
✅ 200 OK
Delete Company
DELETE /api/companies/{id}
Soft-deletes a company (uses Eloquent delete()).
Authorization
- Policy:
deleteonCompany
- 200
- 500
✅ 200 OK