ServiceHub is a multi-role REST API platform built with Laravel 12 that connects service vendors with customers. It provides a full vendor lifecycle β from registration and admin approval to service listing β backed by secure OAuth2 authentication, role-based access control, queued email notifications, and image management.
- Features
- Tech Stack
- Architecture & Roles
- Database Schema
- API Endpoints
- Getting Started
- Environment Variables
- Running the Project
- Testing
- Project Structure
- License
- User registration (customer) and vendor registration (with business profile)
- OAuth2 token-based login via Laravel Passport (Password Grant)
- Role-based access control via Spatie Laravel Permission (
admin,vendor,customer) - Vendor login is blocked until the account is approved by an admin
- List all vendors with pagination
- View vendor details
- Approve or reject vendor applications
- Soft-delete vendors
- Automated email notification sent to vendors on approval/rejection via a queued listener
- Full CRUD for services (create, read, update, delete)
- Each service belongs to a category and a vendor
- Supports multiple image uploads per service (JPEG, PNG, WebP; max 2 MB each)
- Services are uniquely named per vendor and auto-generate SEO-friendly slugs
- Active / inactive status management
- Admins can create, update, and delete service categories
- Vendors can view the category list to use when listing services
- Slugified, with optional description and status toggle
VendorStatusUpdatedEventfires when a vendor is approved or rejectedSendVendorStatusEmailListenerhandles the event and dispatches the appropriate queued email (VendorApprovedMail/VendorRejectedMail)
| Layer | Technology |
|---|---|
| Framework | Laravel 12 |
| Language | PHP 8.2+ |
| Authentication | Laravel Passport (OAuth2) |
| Authorization | Spatie Laravel Permission |
| Database | MySQL |
| Queue | Database queue driver |
| Configurable (SMTP / Mailgun / log) | |
| Asset Bundling | Vite + Tailwind CSS v4 |
| Testing | Pest PHP |
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β Customer β β Vendor β β Admin β
β (register, β β (register, β β (manage β
β login) β β login, β β vendors & β
β β β services) β β categories) β
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β β β
βββββββββββββββββββββββ΄βββββββββββββββββββββββ
β
Laravel REST API (Passport)
Register β Pending β Admin Reviews β Approved β
/ Rejected β
β β
Email sent Email sent
(queued) (queued)
β
Can now login
& list services
| Table | Key Columns |
|---|---|
users |
id, name, email, password |
vendors |
id, user_id (FK), business_name, logo, phone, address, city, status (0=pending, 1=approved, 2=rejected, 3=suspended), deleted_at |
service_categories |
id, name, slug, description, status |
services |
id, vendor_id (FK), category_id (FK), name, slug, short_description, description, price, status (0=inactive, 1=active), deleted_at |
service_images |
id, service_id (FK), path, alt_text |
oauth_* |
Passport OAuth2 tables |
permissions / roles |
Spatie permission tables |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/register |
Register a new customer account |
POST |
/api/vendor/register |
Register a new vendor (pending approval) |
POST |
/api/login |
Login and receive an OAuth2 access token |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/users |
List all users |
GET |
/api/vendors |
List all vendors (paginated) |
GET |
/api/vendors/{id} |
Get a specific vendor |
DELETE |
/api/vendors/{id} |
Soft-delete a vendor |
PATCH |
/api/vendors/{id}/approve |
Approve a vendor |
PATCH |
/api/vendors/{id}/reject |
Reject a vendor |
POST |
/api/service-categories |
Create a service category |
PUT/PATCH |
/api/service-categories/{id} |
Update a service category |
DELETE |
/api/service-categories/{id} |
Delete a service category |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/services |
List all services for authenticated vendor |
POST |
/api/services |
Create a new service with images |
GET |
/api/services/{id} |
Get a specific service |
PUT/PATCH |
/api/services/{id} |
Update a service |
DELETE |
/api/services/{id} |
Delete a service |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/service-categories |
List all service categories |
- PHP >= 8.2
- Composer
- Node.js >= 18 & npm
- MySQL
- A mail service (or use
logdriver for local development)
1. Clone the repository
git clone https://github.com/atanubarua/ServiceHub.git
cd ServiceHub2. Install PHP dependencies
composer install3. Set up environment
cp .env.example .env
php artisan key:generate4. Configure your database in .env:
DB_DATABASE=servicehub
DB_USERNAME=your_db_user
DB_PASSWORD=your_db_password5. Run migrations and seed roles
php artisan migrate
php artisan db:seed6. Install Passport and create OAuth client
php artisan passport:installCopy the generated Password Grant Client ID and Secret into your .env:
PASSPORT_CLIENT_ID=your_client_id
PASSPORT_CLIENT_SECRET=your_client_secret
PASSPORT_LOGIN_ENDPOINT=oauth/token7. Install frontend dependencies
npm installKey variables to configure in .env:
| Variable | Description |
|---|---|
APP_URL |
Base URL of your application |
DB_* |
MySQL database credentials |
QUEUE_CONNECTION |
Set to database (default) or redis |
MAIL_MAILER |
Mail driver (smtp, mailgun, log) |
MAIL_FROM_ADDRESS |
Sender email address |
PASSPORT_CLIENT_ID |
OAuth2 Password Grant client ID |
PASSPORT_CLIENT_SECRET |
OAuth2 Password Grant client secret |
PASSPORT_LOGIN_ENDPOINT |
OAuth token endpoint (default: oauth/token) |
composer setupcomposer devThis runs three concurrent processes:
php artisan serveβ Laravel dev serverphp artisan queue:listenβ processes queued emailsnpm run devβ Vite asset bundler
composer testOr directly:
php artisan testTests are written with Pest PHP.
app/
βββ Events/
β βββ VendorStatusUpdatedEvent.php # Fired on vendor approve/reject
βββ Http/
β βββ Controllers/
β βββ Admin/
β β βββ VendorController.php # Admin vendor management
β βββ Vendor/
β β βββ ServiceController.php # Vendor service CRUD
β βββ AuthController.php # Register & login
β βββ ServiceCategoryController.php
βββ Listeners/
β βββ SendVendorStatusEmailListener.php # Sends queued emails
βββ Mail/
β βββ VendorApprovedMail.php
β βββ VendorRejectedMail.php
βββ Models/
βββ User.php
βββ Vendor.php
βββ Service.php
βββ ServiceCategory.php
βββ ServiceImage.php
database/
βββ migrations/ # All table schemas
βββ seeders/
βββ DatabaseSeeder.php
βββ RoleSeeder.php # Seeds admin, vendor, customer roles
routes/
βββ api.php # All API route definitions
This project is open-sourced software licensed under the MIT license.