A robust RESTful API built with Laravel 10 and PHP 8.1 for managing real estate properties and brokers. The API provides endpoints for authenticating users, managing property details alongside their specific characteristics, and handling broker profiles.
- Authentication: Secure user registration, login, and logout using Laravel Sanctum.
- Broker Management: Full CRUD operations for brokers (Name, Address, City, Zip Code, Phone, Logo).
- Property Management: Complete property listings with relationships to brokers.
- Property Characteristics: Detailed property attributes including price, bedrooms, bathrooms, square footage, price per sqft, property type (Single, Townhouse, Multifamily, Bungalow), and status (Sale, Sold, Hold).
- Role-Based Access:
- Public read access for browsing properties and brokers.
- Protected endpoints for creating, updating, and deleting listings (requires authentication).
- Framework: Laravel 10
- Language: PHP > 8.1
- Database: Configurable via
.env(MySQL / PostgreSQL / SQLite) - Authentication: Laravel Sanctum
POST /api/register- Register a new userPOST /api/login- Authenticate and receive a Sanctum tokenPOST /api/logout- Invalidate the token (Requires Auth)
GET /api/brokers- List all brokers (Public)GET /api/brokers/{broker}- Get a specific broker (Public)POST /api/brokers- Create a new broker (Requires Auth)PUT/PATCH /api/brokers/{broker}- Update a broker (Requires Auth)DELETE /api/brokers/{broker}- Delete a broker (Requires Auth)
GET /api/properties- List all properties (Public)GET /api/properties/{property}- Get a specific property (Public)POST /api/properties- Add a new property (Requires Auth)PUT/PATCH /api/properties/{property}- Update a property (Requires Auth)DELETE /api/properties/{property}- Delete a property (Requires Auth)
Protected endpoints require a Bearer token in the Authorization header:
Authorization: Bearer {your_token_here}
- PHP >= 8.1
- Composer
- A supported database (MySQL, PostgreSQL, etc.)
-
Clone the repository:
git clone <repository-url> cd property-listing-api
-
Install dependencies:
composer install
-
Environment Configuration: Copy the example environment file and configure your database credentials:
cp .env.example .env
Make sure to update
DB_DATABASE,DB_USERNAME, andDB_PASSWORDin your.envfile. -
Generate Application Key:
php artisan key:generate
-
Run Migrations:
php artisan migrate
-
Serve the application:
php artisan serve
The API will be accessible at
http://localhost:8000/api.
This project is open-sourced software licensed under the MIT license.