# RELAMS Module : Property

## 1. Overview

Property is a module that is part of Sites, it is designed to hold all the informations of Property available to the company.


## 2. General Rules:
- Naming is camelcase
- Use plural in namings where it is plural
- use itenary to ensure null and other data types yield result/display empty if false
- returning Json format is ["status": true, "data": [], "message": "Data fetched successfully"] 

## 3.Controller
 The Controller is `app/Http/Controllers/V1/Web/PropertyController.php`

 it should contain the followin functions:

- `index()` - Main function and it fetch all the Property
- `get()` - Eloquent models and domain entities
- `add()` - form to add property.
- `store()` - Store the sent data request to create a property
- `app/Traits/` - shared reusable traits
- `app/Helpers/Helper.php` - global helper functions
- `resources/views/` - Blade templates organized by module
- `resources/js/` - frontend entry points
- `routes/web.php` - web route definitions
- `composer.json` / `package.json` - dependency and script definitions


## 4. Middleware and Controller Architecture

### Controllers
RELAMS is using controllers to define the functionality of the software and is following versioning structure, for the purpose of simplifying scalability and upgrade.
the structure is at follows:
- `Controllers/V1/Web`
- `Controllers/V1/API` etc

The web Controllers are meant to serve the web request via browser. They are as follows :
- `PropertyController`

### Controller Methods
These are the functions expected in the controller:
- index()  for fetching all properties(not null) and it should have a counting stats of : all, active, inactive, reserved, sold, Land(type), Office(type), House(type), Warehouse(type), Shop(type)
- get() for fetching properties and returning in json format. the function may recieve a anchor for filtering such as status and type.
- add() for displaying add form "properties.add"
- store() for storing property
- view(id) for viewing property
- edit(id) for displaying edit form
- update(id) for updating property
- activate(id) for activating status of a property to active
- deactivate(id) for deactivating status of a property to Inactive
- delete(id) for property : changing the status to null

### Middlewares


## 4. Routes Architecture 
these routes should be in group with a prefix "properties"
- `/properties/` → Index | Fetch all the properties
- `/properties/get` → Get all the properties as json format
- `/properties/add` → Add Property form
- `/properties/store` → Store Property data
- `/properties/{id}/view` → View a single Property
- `/properties/{id}/edit` → Edit a single Property
- `/properties/{id}/update` → Update a single Property
- `/properties/{id}/activate` → Activate a single Property
- `/properties/{id}/deactivate` → Deactivate a single Property
- `/properties/{id}/delete` → Delete a single Property
- `/properties/export/form` → Export form of properties
- `/properties/export/download` → Export properties
- `/properties/export/single` → Export a single Property


## 5. db Structure
- id
- business_id
- site_id

- title              → e.g. "Property 12", "3-Bedroom Flat", "Office Suite A"
- unit                  → identifier

- type     → ENUM: Property, house, office, land, warehouse
- usage_type        → optional: rent, sale, lease
- category          -- residential, commercial, industrial etc

- size              → keep generic (sqm, sqft)

- floor             → nullable (for buildings)
- block             → nullable (for estates/malls)

- price
- status            → available, occupied, reserved, etc.
- lat               - optional
- lon               - optional

- description       → optional

- created_by
- updated_by
- timestamps


## 6 Model 
it should have the following
- fillable
- relationship functions
  - user
  - business
  - site
- other function
    - fetching by unit
    - fetching by status