feat: prepare project for production release
This commit is contained in:
commit
36e0a00909
|
|
@ -0,0 +1,18 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[docker-compose.yml]
|
||||
indent_size = 4
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
APP_LOCALE=en
|
||||
APP_FALLBACK_LOCALE=en
|
||||
APP_FAKER_LOCALE=en_US
|
||||
|
||||
APP_MAINTENANCE_DRIVER=file
|
||||
# APP_MAINTENANCE_STORE=database
|
||||
|
||||
PHP_CLI_SERVER_WORKERS=4
|
||||
|
||||
BCRYPT_ROUNDS=12
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_STACK=single
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=sqlite
|
||||
# DB_HOST=127.0.0.1
|
||||
# DB_PORT=3306
|
||||
# DB_DATABASE=laravel
|
||||
# DB_USERNAME=root
|
||||
# DB_PASSWORD=
|
||||
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
SESSION_ENCRYPT=false
|
||||
SESSION_PATH=/
|
||||
SESSION_DOMAIN=null
|
||||
|
||||
BROADCAST_CONNECTION=log
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=database
|
||||
|
||||
CACHE_STORE=database
|
||||
# CACHE_PREFIX=
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_CLIENT=phpredis
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=log
|
||||
MAIL_SCHEME=null
|
||||
MAIL_HOST=127.0.0.1
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_FROM_ADDRESS="hello@example.com"
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
VITE_APP_NAME="${APP_NAME}"
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
* text=auto eol=lf
|
||||
|
||||
*.blade.php diff=html
|
||||
*.css diff=css
|
||||
*.html diff=html
|
||||
*.md diff=markdown
|
||||
*.php diff=php
|
||||
|
||||
/.github export-ignore
|
||||
CHANGELOG.md export-ignore
|
||||
.styleci.yml export-ignore
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
/.phpunit.cache
|
||||
/node_modules
|
||||
/public/build
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/storage/pail
|
||||
/vendor
|
||||
.env
|
||||
.env.backup
|
||||
.env.production
|
||||
.phpactor.json
|
||||
.phpunit.result.cache
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
/auth.json
|
||||
/.fleet
|
||||
/.idea
|
||||
/.nova
|
||||
/.vscode
|
||||
/.zed
|
||||
|
|
@ -0,0 +1,244 @@
|
|||
# Person API Documentation
|
||||
|
||||
This document provides information about the Person API endpoints and how to use them with Postman.
|
||||
|
||||
## API Endpoints
|
||||
|
||||
The API follows RESTful conventions and provides the following endpoints:
|
||||
|
||||
| Method | Endpoint | Description |
|
||||
|--------|--------------------|-------------------------------------------------|
|
||||
| GET | /api/persons | List all persons (with optional search) |
|
||||
| POST | /api/persons | Create a new person with related entities |
|
||||
| GET | /api/persons/{id} | Get a specific person with related entities |
|
||||
| PUT | /api/persons/{id} | Update a person and its related entities |
|
||||
| DELETE | /api/persons/{id} | Delete a person and its related entities |
|
||||
|
||||
## Setup in Postman
|
||||
|
||||
1. Create a new Postman collection called "Person API"
|
||||
2. Set the base URL to your server location (e.g., `http://localhost:8000`)
|
||||
3. Create requests for each of the endpoints listed above
|
||||
|
||||
## Authentication
|
||||
|
||||
The API uses Laravel Sanctum for authentication. To set up authentication in Postman:
|
||||
|
||||
1. Create a login request if your app includes authentication
|
||||
2. Save the token from the response
|
||||
3. For subsequent requests, include the token in the Authorization header:
|
||||
- Type: Bearer Token
|
||||
- Token: [your-token]
|
||||
|
||||
## Request Examples
|
||||
|
||||
### List Persons (GET /api/persons)
|
||||
|
||||
**Query Parameters:**
|
||||
- `search`: Optional search term to filter by full_name, surname, or occupation
|
||||
- `page`: Page number for pagination
|
||||
|
||||
**Example Response:**
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"data": [
|
||||
{
|
||||
"person_id": 1,
|
||||
"surname": "Smith",
|
||||
"christian_name": "John",
|
||||
"full_name": "John Smith",
|
||||
"occupation": "Engineer",
|
||||
"migration": { ... },
|
||||
"naturalization": { ... },
|
||||
"residence": { ... },
|
||||
"family": { ... },
|
||||
"internment": { ... }
|
||||
}
|
||||
],
|
||||
"meta": {
|
||||
"total": 50,
|
||||
"count": 10,
|
||||
"per_page": 10,
|
||||
"current_page": 1,
|
||||
"last_page": 5
|
||||
},
|
||||
"links": {
|
||||
"first": "http://localhost:8000/api/persons?page=1",
|
||||
"last": "http://localhost:8000/api/persons?page=5",
|
||||
"prev": null,
|
||||
"next": "http://localhost:8000/api/persons?page=2"
|
||||
}
|
||||
},
|
||||
"message": "Persons retrieved successfully"
|
||||
}
|
||||
```
|
||||
|
||||
### Create Person (POST /api/persons)
|
||||
|
||||
**Headers:**
|
||||
- Content-Type: application/json
|
||||
|
||||
**Request Body Example:**
|
||||
```json
|
||||
{
|
||||
"surname": "Johnson",
|
||||
"christian_name": "Emily",
|
||||
"full_name": "Emily Johnson",
|
||||
"date_of_birth": "1965-03-15",
|
||||
"place_of_birth": "Sydney",
|
||||
"occupation": "Teacher",
|
||||
"migration": {
|
||||
"date_of_arrival_aus": "1980-05-20",
|
||||
"date_of_arrival_nt": "1980-06-01",
|
||||
"arrival_period": "1980-1990",
|
||||
"data_source": "Government Records"
|
||||
},
|
||||
"naturalization": {
|
||||
"date_of_naturalisation": "1990-07-12",
|
||||
"no_of_cert": "NAT12345",
|
||||
"issued_at": "Darwin"
|
||||
},
|
||||
"residence": {
|
||||
"darwin": true,
|
||||
"katherine": false,
|
||||
"tennant_creek": false,
|
||||
"alice_springs": false,
|
||||
"home_at_death": "Darwin"
|
||||
},
|
||||
"family": {
|
||||
"names_of_parents": "Robert Johnson, Mary Johnson",
|
||||
"names_of_children": "Sarah, Michael, Thomas"
|
||||
},
|
||||
"internment": {
|
||||
"corps_issued": "Australian Army",
|
||||
"interned_in": "Darwin",
|
||||
"sent_to": "Melbourne",
|
||||
"internee_occupation": "Soldier",
|
||||
"internee_address": "123 Main St, Darwin",
|
||||
"cav": "CAV12345"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"person_id": 2,
|
||||
"surname": "Johnson",
|
||||
"christian_name": "Emily",
|
||||
"full_name": "Emily Johnson",
|
||||
"date_of_birth": "1965-03-15",
|
||||
"place_of_birth": "Sydney",
|
||||
"occupation": "Teacher",
|
||||
"migration": { ... },
|
||||
"naturalization": { ... },
|
||||
"residence": { ... },
|
||||
"family": { ... },
|
||||
"internment": { ... }
|
||||
},
|
||||
"message": "Person created successfully"
|
||||
}
|
||||
```
|
||||
|
||||
### Get Person (GET /api/persons/{id})
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"person_id": 2,
|
||||
"surname": "Johnson",
|
||||
"christian_name": "Emily",
|
||||
"full_name": "Emily Johnson",
|
||||
"date_of_birth": "1965-03-15",
|
||||
"place_of_birth": "Sydney",
|
||||
"occupation": "Teacher",
|
||||
"migration": { ... },
|
||||
"naturalization": { ... },
|
||||
"residence": { ... },
|
||||
"family": { ... },
|
||||
"internment": { ... }
|
||||
},
|
||||
"message": "Person retrieved successfully"
|
||||
}
|
||||
```
|
||||
|
||||
### Update Person (PUT /api/persons/{id})
|
||||
|
||||
**Headers:**
|
||||
- Content-Type: application/json
|
||||
|
||||
**Request Body Example:**
|
||||
```json
|
||||
{
|
||||
"surname": "Johnson-Smith",
|
||||
"occupation": "Professor",
|
||||
"residence": {
|
||||
"darwin": true,
|
||||
"katherine": true,
|
||||
"home_at_death": "Katherine"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"person_id": 2,
|
||||
"surname": "Johnson-Smith",
|
||||
"christian_name": "Emily",
|
||||
"full_name": "Emily Johnson",
|
||||
"occupation": "Professor",
|
||||
"migration": { ... },
|
||||
"naturalization": { ... },
|
||||
"residence": {
|
||||
"residence_id": 2,
|
||||
"darwin": true,
|
||||
"katherine": true,
|
||||
"tennant_creek": false,
|
||||
"alice_springs": false,
|
||||
"home_at_death": "Katherine"
|
||||
},
|
||||
"family": { ... },
|
||||
"internment": { ... }
|
||||
},
|
||||
"message": "Person updated successfully"
|
||||
}
|
||||
```
|
||||
|
||||
### Delete Person (DELETE /api/persons/{id})
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Person deleted successfully"
|
||||
}
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
All API responses include a `success` flag that indicates whether the request was successful. In case of an error, the response will include a descriptive message:
|
||||
|
||||
```json
|
||||
{
|
||||
"success": false,
|
||||
"message": "Failed to retrieve person",
|
||||
"error": "Person not found"
|
||||
}
|
||||
```
|
||||
|
||||
## Testing the API
|
||||
|
||||
The API includes comprehensive test coverage. You can run the tests using:
|
||||
|
||||
```bash
|
||||
php artisan test --filter=PersonApiTest
|
||||
```
|
||||
|
|
@ -0,0 +1,285 @@
|
|||
# Authentication API Testing Guide
|
||||
|
||||
This document provides instructions for testing the authentication system using Postman, including examples of API calls and how to use the authentication tokens with protected endpoints.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. Ensure you've run database migrations and seeders:
|
||||
```bash
|
||||
php artisan migrate
|
||||
php artisan db:seed
|
||||
```
|
||||
|
||||
2. The system has created two test users:
|
||||
- Admin User: `admin@example.com` / `Admin123!`
|
||||
- Regular User: `user@example.com` (password was auto-generated)
|
||||
|
||||
## Postman Collection Setup
|
||||
|
||||
1. Create a new Postman Collection called "Person Management API"
|
||||
2. Set up environment variables:
|
||||
- `base_url`: Your API base URL (e.g., `http://localhost:8000/api`)
|
||||
- `admin_token`: Will store the admin authentication token
|
||||
- `user_token`: Will store the regular user authentication token
|
||||
|
||||
## Test Scenarios
|
||||
|
||||
### 1. Authentication Flow
|
||||
|
||||
#### 1.1 Admin Login
|
||||
|
||||
**Request:**
|
||||
- Method: `POST`
|
||||
- URL: `{{base_url}}/login`
|
||||
- Headers:
|
||||
- Content-Type: `application/json`
|
||||
- Accept: `application/json`
|
||||
- Body (raw JSON):
|
||||
```json
|
||||
{
|
||||
"email": "admin@example.com",
|
||||
"password": "Admin123!",
|
||||
"device_name": "postman"
|
||||
}
|
||||
```
|
||||
|
||||
**Postman Test Script:**
|
||||
```javascript
|
||||
// Parse response
|
||||
var jsonData = pm.response.json();
|
||||
|
||||
// Test response structure
|
||||
pm.test("Status code is 200", function () {
|
||||
pm.response.to.have.status(200);
|
||||
});
|
||||
|
||||
pm.test("Response has correct structure", function () {
|
||||
pm.expect(jsonData.success).to.eql(true);
|
||||
pm.expect(jsonData.data).to.have.property('token');
|
||||
pm.expect(jsonData.data.user).to.have.property('is_admin');
|
||||
pm.expect(jsonData.data.user.is_admin).to.eql(true);
|
||||
});
|
||||
|
||||
// Save token to environment variable
|
||||
if (jsonData.data && jsonData.data.token) {
|
||||
pm.environment.set("admin_token", jsonData.data.token);
|
||||
}
|
||||
```
|
||||
|
||||
#### 1.2 Get Admin Profile
|
||||
|
||||
**Request:**
|
||||
- Method: `GET`
|
||||
- URL: `{{base_url}}/user`
|
||||
- Headers:
|
||||
- Accept: `application/json`
|
||||
- Authorization: `Bearer {{admin_token}}`
|
||||
|
||||
**Postman Test Script:**
|
||||
```javascript
|
||||
var jsonData = pm.response.json();
|
||||
|
||||
pm.test("Status code is 200", function () {
|
||||
pm.response.to.have.status(200);
|
||||
});
|
||||
|
||||
pm.test("User is admin", function () {
|
||||
pm.expect(jsonData.data.user.is_admin).to.eql(true);
|
||||
});
|
||||
```
|
||||
|
||||
#### 1.3 Register a New User (Admin Only)
|
||||
|
||||
**Request:**
|
||||
- Method: `POST`
|
||||
- URL: `{{base_url}}/register`
|
||||
- Headers:
|
||||
- Content-Type: `application/json`
|
||||
- Accept: `application/json`
|
||||
- Authorization: `Bearer {{admin_token}}`
|
||||
- Body (raw JSON):
|
||||
```json
|
||||
{
|
||||
"name": "New Test User",
|
||||
"email": "newuser@example.com",
|
||||
"password": "Password123!",
|
||||
"is_admin": false
|
||||
}
|
||||
```
|
||||
|
||||
**Postman Test Script:**
|
||||
```javascript
|
||||
var jsonData = pm.response.json();
|
||||
|
||||
pm.test("Status code is 201", function () {
|
||||
pm.response.to.have.status(201);
|
||||
});
|
||||
|
||||
pm.test("User created successfully", function () {
|
||||
pm.expect(jsonData.success).to.eql(true);
|
||||
pm.expect(jsonData.message).to.eql("User created successfully");
|
||||
});
|
||||
```
|
||||
|
||||
#### 1.4 Login as New User
|
||||
|
||||
**Request:**
|
||||
- Method: `POST`
|
||||
- URL: `{{base_url}}/login`
|
||||
- Headers:
|
||||
- Content-Type: `application/json`
|
||||
- Accept: `application/json`
|
||||
- Body (raw JSON):
|
||||
```json
|
||||
{
|
||||
"email": "newuser@example.com",
|
||||
"password": "Password123!",
|
||||
"device_name": "postman"
|
||||
}
|
||||
```
|
||||
|
||||
**Postman Test Script:**
|
||||
```javascript
|
||||
var jsonData = pm.response.json();
|
||||
|
||||
pm.test("Status code is 200", function () {
|
||||
pm.response.to.have.status(200);
|
||||
});
|
||||
|
||||
// Save token to environment variable
|
||||
if (jsonData.data && jsonData.data.token) {
|
||||
pm.environment.set("user_token", jsonData.data.token);
|
||||
}
|
||||
```
|
||||
|
||||
#### 1.5 Regular User Cannot Register New Users
|
||||
|
||||
**Request:**
|
||||
- Method: `POST`
|
||||
- URL: `{{base_url}}/register`
|
||||
- Headers:
|
||||
- Content-Type: `application/json`
|
||||
- Accept: `application/json`
|
||||
- Authorization: `Bearer {{user_token}}`
|
||||
- Body (raw JSON):
|
||||
```json
|
||||
{
|
||||
"name": "Another User",
|
||||
"email": "another@example.com",
|
||||
"password": "Password123!",
|
||||
"is_admin": false
|
||||
}
|
||||
```
|
||||
|
||||
**Postman Test Script:**
|
||||
```javascript
|
||||
pm.test("Status code is 403 (Forbidden)", function () {
|
||||
pm.response.to.have.status(403);
|
||||
});
|
||||
```
|
||||
|
||||
#### 1.6 Logout Admin
|
||||
|
||||
**Request:**
|
||||
- Method: `POST`
|
||||
- URL: `{{base_url}}/logout`
|
||||
- Headers:
|
||||
- Accept: `application/json`
|
||||
- Authorization: `Bearer {{admin_token}}`
|
||||
|
||||
**Postman Test Script:**
|
||||
```javascript
|
||||
var jsonData = pm.response.json();
|
||||
|
||||
pm.test("Status code is 200", function () {
|
||||
pm.response.to.have.status(200);
|
||||
});
|
||||
|
||||
pm.test("Logged out successfully", function () {
|
||||
pm.expect(jsonData.success).to.eql(true);
|
||||
pm.expect(jsonData.message).to.eql("Logged out successfully");
|
||||
});
|
||||
|
||||
// Clear token from environment
|
||||
pm.environment.unset("admin_token");
|
||||
```
|
||||
|
||||
### 2. Accessing Protected API Endpoints
|
||||
|
||||
#### 2.1 Trying to Access Protected Endpoint Without Token
|
||||
|
||||
**Request:**
|
||||
- Method: `GET`
|
||||
- URL: `{{base_url}}/persons`
|
||||
- Headers:
|
||||
- Accept: `application/json`
|
||||
|
||||
**Postman Test Script:**
|
||||
```javascript
|
||||
pm.test("Status code is 401 (Unauthorized)", function () {
|
||||
pm.response.to.have.status(401);
|
||||
});
|
||||
```
|
||||
|
||||
#### 2.2 Accessing Protected Endpoint With Token
|
||||
|
||||
**Request:**
|
||||
- Method: `GET`
|
||||
- URL: `{{base_url}}/persons`
|
||||
- Headers:
|
||||
- Accept: `application/json`
|
||||
- Authorization: `Bearer {{user_token}}`
|
||||
|
||||
**Postman Test Script:**
|
||||
```javascript
|
||||
var jsonData = pm.response.json();
|
||||
|
||||
pm.test("Status code is 200", function () {
|
||||
pm.response.to.have.status(200);
|
||||
});
|
||||
|
||||
pm.test("Response has correct structure", function () {
|
||||
pm.expect(jsonData.success).to.eql(true);
|
||||
pm.expect(jsonData).to.have.property('data');
|
||||
});
|
||||
```
|
||||
|
||||
## Automated Testing Sequence
|
||||
|
||||
To create an automated test sequence in Postman:
|
||||
|
||||
1. Create a folder for "Authentication Tests" in your collection
|
||||
2. Add all the test requests above to this folder
|
||||
3. Right-click on the folder and select "Run"
|
||||
4. In the Collection Runner, deselect any requests you don't want to run
|
||||
5. Click "Run" to execute the tests in sequence
|
||||
|
||||
## Using PostmanTestAPI.json Collection
|
||||
|
||||
A complete Postman collection has been provided in this repository. To use it:
|
||||
|
||||
1. In Postman, click on "Import"
|
||||
2. Upload or paste the contents of `PostmanTestAPI.json`
|
||||
3. Create an environment with the variable `base_url` set to your API URL
|
||||
4. Run the collection
|
||||
|
||||
## Automated Test Script
|
||||
|
||||
You can also run the tests using Newman (Postman's command-line runner):
|
||||
|
||||
```bash
|
||||
# Install Newman
|
||||
npm install -g newman
|
||||
|
||||
# Run the collection
|
||||
newman run PostmanTestAPI.json -e environment.json
|
||||
```
|
||||
|
||||
## Security Best Practices Implemented
|
||||
|
||||
1. **Token-based Authentication**: Using Laravel Sanctum for secure API tokens
|
||||
2. **Password Hashing**: All passwords are hashed using bcrypt
|
||||
3. **Role-based Access Control**: Admin-specific endpoints protected
|
||||
4. **Token Abilities**: Tokens are created with specific abilities based on user role
|
||||
5. **Token Revocation**: Tokens can be revoked on logout
|
||||
6. **Request Validation**: All inputs are validated before processing
|
||||
|
|
@ -0,0 +1,599 @@
|
|||
{
|
||||
"info": {
|
||||
"_postman_id": "f87e5a2c-ddf8-4bb3-82e6-e9c5f6bb8de9",
|
||||
"name": "Person Management API",
|
||||
"description": "A collection to test the Person API with authentication",
|
||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
||||
},
|
||||
"item": [
|
||||
{
|
||||
"name": "Authentication Tests",
|
||||
"item": [
|
||||
{
|
||||
"name": "Admin Login",
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"exec": [
|
||||
"// Parse response",
|
||||
"var jsonData = pm.response.json();",
|
||||
"",
|
||||
"// Test response structure",
|
||||
"pm.test(\"Status code is 200\", function () {",
|
||||
" pm.response.to.have.status(200);",
|
||||
"});",
|
||||
"",
|
||||
"pm.test(\"Response has correct structure\", function () {",
|
||||
" pm.expect(jsonData.success).to.eql(true);",
|
||||
" pm.expect(jsonData.data).to.have.property('token');",
|
||||
" pm.expect(jsonData.data.user).to.have.property('is_admin');",
|
||||
" pm.expect(jsonData.data.user.is_admin).to.eql(true);",
|
||||
"});",
|
||||
"",
|
||||
"// Save token to environment variable",
|
||||
"if (jsonData.data && jsonData.data.token) {",
|
||||
" pm.environment.set(\"admin_token\", jsonData.data.token);",
|
||||
"}"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Accept",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"email\": \"admin@example.com\",\n \"password\": \"Admin123!\",\n \"device_name\": \"postman\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{base_url}}/login",
|
||||
"host": [
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"login"
|
||||
]
|
||||
},
|
||||
"description": "Login as Admin user and store token in environment variable"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Get Admin Profile",
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"exec": [
|
||||
"var jsonData = pm.response.json();",
|
||||
"",
|
||||
"pm.test(\"Status code is 200\", function () {",
|
||||
" pm.response.to.have.status(200);",
|
||||
"});",
|
||||
"",
|
||||
"pm.test(\"User is admin\", function () {",
|
||||
" pm.expect(jsonData.data.user.is_admin).to.eql(true);",
|
||||
"});"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [
|
||||
{
|
||||
"key": "Accept",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Authorization",
|
||||
"value": "Bearer {{admin_token}}"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "{{base_url}}/user",
|
||||
"host": [
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"user"
|
||||
]
|
||||
},
|
||||
"description": "Get authenticated admin user profile"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Register New User (Admin Only)",
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"exec": [
|
||||
"var jsonData = pm.response.json();",
|
||||
"",
|
||||
"pm.test(\"Status code is 201\", function () {",
|
||||
" pm.response.to.have.status(201);",
|
||||
"});",
|
||||
"",
|
||||
"pm.test(\"User created successfully\", function () {",
|
||||
" pm.expect(jsonData.success).to.eql(true);",
|
||||
" pm.expect(jsonData.message).to.eql(\"User created successfully\");",
|
||||
"});"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Accept",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Authorization",
|
||||
"value": "Bearer {{admin_token}}"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"name\": \"New Test User\",\n \"email\": \"newuser@example.com\",\n \"password\": \"Password123!\",\n \"is_admin\": false\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{base_url}}/register",
|
||||
"host": [
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"register"
|
||||
]
|
||||
},
|
||||
"description": "Register a new user (admin only can do this)"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Login as New User",
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"exec": [
|
||||
"var jsonData = pm.response.json();",
|
||||
"",
|
||||
"pm.test(\"Status code is 200\", function () {",
|
||||
" pm.response.to.have.status(200);",
|
||||
"});",
|
||||
"",
|
||||
"// Save token to environment variable",
|
||||
"if (jsonData.data && jsonData.data.token) {",
|
||||
" pm.environment.set(\"user_token\", jsonData.data.token);",
|
||||
"}"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Accept",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"email\": \"newuser@example.com\",\n \"password\": \"Password123!\",\n \"device_name\": \"postman\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{base_url}}/login",
|
||||
"host": [
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"login"
|
||||
]
|
||||
},
|
||||
"description": "Login as the newly created user"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Regular User Cannot Register New Users",
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"exec": [
|
||||
"pm.test(\"Status code is 403 (Forbidden)\", function () {",
|
||||
" pm.response.to.have.status(403);",
|
||||
"});"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Accept",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Authorization",
|
||||
"value": "Bearer {{user_token}}"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"name\": \"Another User\",\n \"email\": \"another@example.com\",\n \"password\": \"Password123!\",\n \"is_admin\": false\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{base_url}}/register",
|
||||
"host": [
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"register"
|
||||
]
|
||||
},
|
||||
"description": "Test that a regular user cannot register new users"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Logout Admin",
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"exec": [
|
||||
"var jsonData = pm.response.json();",
|
||||
"",
|
||||
"pm.test(\"Status code is 200\", function () {",
|
||||
" pm.response.to.have.status(200);",
|
||||
"});",
|
||||
"",
|
||||
"pm.test(\"Logged out successfully\", function () {",
|
||||
" pm.expect(jsonData.success).to.eql(true);",
|
||||
" pm.expect(jsonData.message).to.eql(\"Logged out successfully\");",
|
||||
"});",
|
||||
"",
|
||||
"// Clear token from environment",
|
||||
"pm.environment.unset(\"admin_token\");"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Accept",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Authorization",
|
||||
"value": "Bearer {{admin_token}}"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "{{base_url}}/logout",
|
||||
"host": [
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"logout"
|
||||
]
|
||||
},
|
||||
"description": "Logout admin user (revoke token)"
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
],
|
||||
"description": "Tests for the authentication system"
|
||||
},
|
||||
{
|
||||
"name": "Protected API Endpoints",
|
||||
"item": [
|
||||
{
|
||||
"name": "Access Without Token (Unauthorized)",
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"exec": [
|
||||
"pm.test(\"Status code is 401 (Unauthorized)\", function () {",
|
||||
" pm.response.to.have.status(401);",
|
||||
"});"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [
|
||||
{
|
||||
"key": "Accept",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "{{base_url}}/persons",
|
||||
"host": [
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"persons"
|
||||
]
|
||||
},
|
||||
"description": "Try to access a protected endpoint without a token"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "List Persons (With Token)",
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"exec": [
|
||||
"var jsonData = pm.response.json();",
|
||||
"",
|
||||
"pm.test(\"Status code is 200\", function () {",
|
||||
" pm.response.to.have.status(200);",
|
||||
"});",
|
||||
"",
|
||||
"pm.test(\"Response has correct structure\", function () {",
|
||||
" pm.expect(jsonData.success).to.eql(true);",
|
||||
" pm.expect(jsonData).to.have.property('data');",
|
||||
"});"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [
|
||||
{
|
||||
"key": "Accept",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Authorization",
|
||||
"value": "Bearer {{user_token}}"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "{{base_url}}/persons",
|
||||
"host": [
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"persons"
|
||||
]
|
||||
},
|
||||
"description": "List all persons (protected endpoint)"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Create Person (With Token)",
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"exec": [
|
||||
"var jsonData = pm.response.json();",
|
||||
"",
|
||||
"pm.test(\"Status code is 201\", function () {",
|
||||
" pm.response.to.have.status(201);",
|
||||
"});",
|
||||
"",
|
||||
"pm.test(\"Person created successfully\", function () {",
|
||||
" pm.expect(jsonData.success).to.eql(true);",
|
||||
" pm.expect(jsonData.message).to.eql(\"Person created successfully\");",
|
||||
"});",
|
||||
"",
|
||||
"// Save person ID for later tests",
|
||||
"if (jsonData.data && jsonData.data.person_id) {",
|
||||
" pm.environment.set(\"person_id\", jsonData.data.person_id);",
|
||||
"}"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Accept",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Authorization",
|
||||
"value": "Bearer {{user_token}}"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"surname\": \"Chen\",\n \"christian_name\": \"Michael\",\n \"full_name\": \"Michael Chen\",\n \"date_of_birth\": \"1965-04-18\",\n \"place_of_birth\": \"Hong Kong\",\n \"occupation\": \"Merchant\",\n \"id_card_no\": \"ID-583921\",\n \n \"migration\": {\n \"date_of_arrival_aus\": \"1982-03-17\",\n \"date_of_arrival_nt\": \"1982-04-01\",\n \"arrival_period\": \"1980-1990\"\n },\n \n \"residence\": {\n \"darwin\": true,\n \"katherine\": false,\n \"tennant_creek\": false,\n \"alice_springs\": false\n }\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{base_url}}/persons",
|
||||
"host": [
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"persons"
|
||||
]
|
||||
},
|
||||
"description": "Create a new person (protected endpoint)"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Get Person by ID (With Token)",
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"exec": [
|
||||
"var jsonData = pm.response.json();",
|
||||
"",
|
||||
"pm.test(\"Status code is 200\", function () {",
|
||||
" pm.response.to.have.status(200);",
|
||||
"});",
|
||||
"",
|
||||
"pm.test(\"Person retrieved successfully\", function () {",
|
||||
" pm.expect(jsonData.success).to.eql(true);",
|
||||
" pm.expect(jsonData.message).to.eql(\"Person retrieved successfully\");",
|
||||
"});"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [
|
||||
{
|
||||
"key": "Accept",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Authorization",
|
||||
"value": "Bearer {{user_token}}"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "{{base_url}}/persons/{{person_id}}",
|
||||
"host": [
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"persons",
|
||||
"{{person_id}}"
|
||||
]
|
||||
},
|
||||
"description": "Get person by ID (protected endpoint)"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Find Person by ID Card (With Token)",
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"exec": [
|
||||
"var jsonData = pm.response.json();",
|
||||
"",
|
||||
"pm.test(\"Status code is 200\", function () {",
|
||||
" pm.response.to.have.status(200);",
|
||||
"});",
|
||||
"",
|
||||
"pm.test(\"Person found by ID card\", function () {",
|
||||
" pm.expect(jsonData.success).to.eql(true);",
|
||||
" pm.expect(jsonData.message).to.eql(\"Person found by ID card number\");",
|
||||
"});"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [
|
||||
{
|
||||
"key": "Accept",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Authorization",
|
||||
"value": "Bearer {{user_token}}"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "{{base_url}}/persons/id-card/ID-583921",
|
||||
"host": [
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"persons",
|
||||
"id-card",
|
||||
"ID-583921"
|
||||
]
|
||||
},
|
||||
"description": "Find person by ID card number (protected endpoint)"
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
],
|
||||
"description": "Tests for the protected API endpoints requiring authentication token"
|
||||
}
|
||||
],
|
||||
"event": [
|
||||
{
|
||||
"listen": "prerequest",
|
||||
"script": {
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
""
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
""
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"variable": [
|
||||
{
|
||||
"key": "base_url",
|
||||
"value": "http://localhost:8000/api",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
||||
</p>
|
||||
|
||||
## About Laravel
|
||||
|
||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||
|
||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||
|
||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||
|
||||
## Learning Laravel
|
||||
|
||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
|
||||
|
||||
You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
|
||||
|
||||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||
|
||||
## Laravel Sponsors
|
||||
|
||||
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
|
||||
|
||||
### Premium Partners
|
||||
|
||||
- **[Vehikl](https://vehikl.com)**
|
||||
- **[Tighten Co.](https://tighten.co)**
|
||||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||
- **[64 Robots](https://64robots.com)**
|
||||
- **[Curotec](https://www.curotec.com/services/technologies/laravel)**
|
||||
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
|
||||
- **[Redberry](https://redberry.international/laravel-development)**
|
||||
- **[Active Logic](https://activelogic.com)**
|
||||
|
||||
## Contributing
|
||||
|
||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||
|
||||
## Security Vulnerabilities
|
||||
|
||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||
|
||||
## License
|
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
class ActivityLogController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$logs = Activity::with('causer')
|
||||
->latest()
|
||||
->take(10)
|
||||
->get()
|
||||
->map(function ($log) {
|
||||
return [
|
||||
'log_name' => $log->log_name,
|
||||
'description' => $log->description,
|
||||
'causer_name' => optional($log->causer)->name ?? 'System',
|
||||
'subject_id' => $log->subject_id,
|
||||
'created_at' => $log->created_at->toDateTimeString(),
|
||||
'updated_at' => $log->updated_at->toDateTimeString(),
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $logs,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,202 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
/**
|
||||
* Register a new user
|
||||
*
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function register(Request $request): JsonResponse
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
'password' => 'required|string|min:8',
|
||||
]);
|
||||
|
||||
$user = User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'User created successfully',
|
||||
'data' => $user
|
||||
], 201);
|
||||
}
|
||||
|
||||
public function getAllUsers(Request $request): JsonResponse
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
// Optional: Ensure only users with 'admin' ability can access this
|
||||
if (!$user || !$request->user()->tokenCan('admin')) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Unauthorized'
|
||||
], 403);
|
||||
}
|
||||
|
||||
$users = User::all();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $users
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Login and generate token
|
||||
*
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function login(Request $request): JsonResponse
|
||||
{
|
||||
$request->headers->set('Accept', 'application/json');
|
||||
|
||||
$request->validate([
|
||||
'email' => 'required|email',
|
||||
'password' => 'required',
|
||||
'device_name' => 'nullable|string',
|
||||
]);
|
||||
|
||||
$user = User::where('email', $request->email)->first();
|
||||
|
||||
if (!$user || !Hash::check($request->password, $user->password)) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Invalid credentials',
|
||||
], 401);
|
||||
}
|
||||
|
||||
// Delete existing tokens for the same device name
|
||||
if ($request->device_name) {
|
||||
$user->tokens()->where('name', $request->device_name)->delete();
|
||||
}
|
||||
|
||||
// All users will get the same 'admin' ability (since dashboard is admin-only)
|
||||
$token = $user->createToken($request->device_name ?? 'api_token', ['admin']);
|
||||
|
||||
$tokenExpiration = null;
|
||||
$expirationMinutes = config('sanctum.expiration');
|
||||
if ($expirationMinutes) {
|
||||
$tokenExpiration = now()->addMinutes($expirationMinutes)->toDateTimeString();
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'User signed in successfully',
|
||||
'token' => $token->plainTextToken,
|
||||
'token_type' => 'Bearer',
|
||||
'expires_at' => $tokenExpiration,
|
||||
'user' => [
|
||||
'id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'email' => $user->email,
|
||||
'abilities' => ['admin']
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update authenticated user's account
|
||||
*
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
// Validate incoming request
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|email|unique:users,email,' . $user->id,
|
||||
'current_password' => 'required|string',
|
||||
'password' => 'nullable|string|confirmed|min:6',
|
||||
]);
|
||||
|
||||
// Check if current password is correct
|
||||
if (!\Hash::check($request->current_password, $user->password)) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Current password is incorrect',
|
||||
], 422);
|
||||
}
|
||||
|
||||
// Update user data
|
||||
$user->name = $request->name;
|
||||
$user->email = $request->email;
|
||||
|
||||
if ($request->filled('password')) {
|
||||
$user->password = bcrypt($request->password);
|
||||
}
|
||||
|
||||
$user->save();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Account updated successfully',
|
||||
'user' => $user,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logout (revoke token)
|
||||
*
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function logout(Request $request): JsonResponse
|
||||
{
|
||||
$request->user()->currentAccessToken()->delete();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Logged out successfully'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the authenticated user
|
||||
*
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function me(Request $request): JsonResponse
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
if (!$user) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'User not authenticated',
|
||||
], 401);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => [
|
||||
'user' => [
|
||||
'id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'email' => $user->email,
|
||||
],
|
||||
'abilities' => $request->user()->currentAccessToken()?->abilities ?? [],
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Person;
|
||||
use App\Models\Migration;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public function getStats()
|
||||
{
|
||||
// Total migrants count
|
||||
$totalMigrants = Person::count();
|
||||
|
||||
// New migrants in the current month
|
||||
$currentMonthStart = Carbon::now()->startOfMonth();
|
||||
$newThisMonth = Person::where('created_at', '>=', $currentMonthStart)->count();
|
||||
|
||||
// Recent additions (last 30 days)
|
||||
$thirtyDaysAgo = Carbon::now()->subDays(30);
|
||||
$recentAdditions = Person::where('created_at', '>=', $thirtyDaysAgo)->count();
|
||||
|
||||
// Pending reviews - example: people with missing information
|
||||
$pendingReviews = Person::whereNull('date_of_birth')
|
||||
->orWhereNull('place_of_birth')
|
||||
->orWhereNull('occupation')
|
||||
->count();
|
||||
|
||||
// Incomplete records - persons missing multiple key fields
|
||||
$incompleteRecords = Person::where(function($query) {
|
||||
$query->whereNull('date_of_birth')
|
||||
->orWhereNull('place_of_birth');
|
||||
})
|
||||
->where(function($query) {
|
||||
$query->whereNull('occupation')
|
||||
->orWhereNull('reference')
|
||||
->orWhereNull('id_card_no');
|
||||
})
|
||||
->count();
|
||||
|
||||
// Find peak migration period (by year)
|
||||
$peakMigrationYear = Migration::select(DB::raw('YEAR(date_of_arrival_nt) as year'), DB::raw('COUNT(*) as count'))
|
||||
->whereNotNull('date_of_arrival_nt')
|
||||
->groupBy(DB::raw('YEAR(date_of_arrival_nt)'))
|
||||
->orderBy('count', 'desc')
|
||||
->first();
|
||||
|
||||
// Find most common place of birth
|
||||
$mostCommonOrigin = Person::select('place_of_birth', DB::raw('COUNT(*) as count'))
|
||||
->whereNotNull('place_of_birth')
|
||||
->where('place_of_birth', '!=', '')
|
||||
->groupBy('place_of_birth')
|
||||
->orderBy('count', 'desc')
|
||||
->first();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => [
|
||||
'total_migrants' => $totalMigrants,
|
||||
'new_this_month' => $newThisMonth,
|
||||
'recent_additions' => $recentAdditions,
|
||||
'pending_reviews' => $pendingReviews,
|
||||
'incomplete_records' => $incompleteRecords,
|
||||
'peak_migration_year' => $peakMigrationYear ? [
|
||||
'year' => $peakMigrationYear->year,
|
||||
'count' => $peakMigrationYear->count
|
||||
] : null,
|
||||
'most_common_origin' => $mostCommonOrigin ? [
|
||||
'place' => $mostCommonOrigin->place_of_birth,
|
||||
'count' => $mostCommonOrigin->count
|
||||
] : null
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,543 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\StorePersonRequest;
|
||||
use App\Http\Requests\UpdatePersonRequest;
|
||||
use App\Models\Person;
|
||||
use App\Models\Photo;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Str;
|
||||
use Exception;
|
||||
|
||||
class MigrantController extends Controller
|
||||
{
|
||||
protected array $relations = ['migration', 'naturalization', 'residence', 'family', 'internment'];
|
||||
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
// Include photos in relations
|
||||
$relations = [
|
||||
'migration',
|
||||
'naturalization',
|
||||
'residence',
|
||||
'family',
|
||||
'internment',
|
||||
'photos', // 🔥 Include photos
|
||||
];
|
||||
|
||||
$query = Person::with($relations);
|
||||
$joinedMigration = false;
|
||||
|
||||
// Filtering
|
||||
$query->where(function ($outerQuery) use ($request) {
|
||||
if ($request->filled('full_name')) {
|
||||
$outerQuery->orWhere('full_name', 'LIKE', '%' . $request->input('full_name') . '%');
|
||||
}
|
||||
|
||||
if ($request->filled('christian_name')) {
|
||||
$outerQuery->orWhere('christian_name', 'LIKE', '%' . $request->input('christian_name') . '%');
|
||||
}
|
||||
|
||||
if ($request->filled('surname')) {
|
||||
$outerQuery->orWhere('surname', 'LIKE', '%' . $request->input('surname') . '%');
|
||||
}
|
||||
|
||||
if ($request->filled('place_of_birth')) {
|
||||
$outerQuery->orWhere('place_of_birth', 'LIKE', '%' . $request->input('place_of_birth') . '%');
|
||||
}
|
||||
|
||||
if ($request->filled('occupation')) {
|
||||
$outerQuery->orWhere('occupation', 'LIKE', '%' . $request->input('occupation') . '%');
|
||||
}
|
||||
|
||||
if ($request->filled('date_of_birth')) {
|
||||
$outerQuery->orWhereDate('date_of_birth', $request->input('date_of_birth'));
|
||||
}
|
||||
|
||||
if ($request->filled('arrival_from') || $request->filled('arrival_to')) {
|
||||
$outerQuery->orWhereHas('migration', function ($mq) use ($request) {
|
||||
if ($request->filled('arrival_from') && $request->filled('arrival_to')) {
|
||||
$mq->whereBetween('date_of_arrival_nt', [
|
||||
$request->input('arrival_from'),
|
||||
$request->input('arrival_to')
|
||||
]);
|
||||
} elseif ($request->filled('arrival_from')) {
|
||||
$mq->where('date_of_arrival_nt', '>=', $request->input('arrival_from'));
|
||||
} elseif ($request->filled('arrival_to')) {
|
||||
$mq->where('date_of_arrival_nt', '<=', $request->input('arrival_to'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->filled('town_or_city')) {
|
||||
$outerQuery->orWhereHas('residence', function ($rq) use ($request) {
|
||||
$rq->where('town_or_city', 'LIKE', '%' . $request->input('town_or_city') . '%');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Sorting
|
||||
$sortBy = $request->input('sort_by', 'created_at');
|
||||
$sortOrder = $request->input('sort_order', 'desc');
|
||||
$secondarySortBy = $request->input('secondary_sort_by');
|
||||
$secondarySortOrder = $request->input('secondary_sort_order', 'asc');
|
||||
|
||||
if ($sortBy === 'date_of_arrival_nt') {
|
||||
$query->leftJoin('migration', 'migration.person_id', '=', 'person.person_id');
|
||||
$joinedMigration = true;
|
||||
$query->select('person.*')->orderBy('migration.date_of_arrival_nt', $sortOrder);
|
||||
} elseif (in_array($sortBy, ['full_name', 'christian_name', 'surname'])) {
|
||||
$query->orderBy("person.$sortBy", $sortOrder);
|
||||
} else {
|
||||
$query->orderBy('person.created_at', 'desc');
|
||||
}
|
||||
|
||||
if ($secondarySortBy === 'date_of_arrival_nt') {
|
||||
if (!$joinedMigration) {
|
||||
$query->leftJoin('migration', 'migration.person_id', '=', 'person.person_id');
|
||||
$query->select('person.*');
|
||||
}
|
||||
$query->orderBy('migration.date_of_arrival_nt', $secondarySortOrder);
|
||||
} elseif (in_array($secondarySortBy, ['full_name', 'christian_name', 'surname'])) {
|
||||
$query->orderBy("person.$secondarySortBy", $secondarySortOrder);
|
||||
}
|
||||
|
||||
// Pagination
|
||||
$perPage = $request->input('per_page', 10);
|
||||
$results = $query->paginate($perPage);
|
||||
|
||||
// Optionally map photo URLs (if you need full URLs or extra processing)
|
||||
$results->getCollection()->transform(function ($person) {
|
||||
$person->photos->transform(function ($photo) {
|
||||
$photo->url = asset('storage/' . $photo->path); // or whatever logic you have
|
||||
return $photo;
|
||||
});
|
||||
return $person;
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $results,
|
||||
'message' => 'Persons retrieved successfully',
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
\Log::error('Error retrieving persons: ' . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Failed to retrieve persons',
|
||||
'error' => $e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function show(string $id): JsonResponse
|
||||
{
|
||||
try {
|
||||
$person = Person::with(array_merge($this->relations, ['photos']))->find($id);
|
||||
|
||||
if ($person) {
|
||||
// Add full URLs to photos
|
||||
$person->photos->transform(function ($photo) {
|
||||
$photo->url = asset('storage/' . $photo->path); // Adjust if needed
|
||||
return $photo;
|
||||
});
|
||||
|
||||
return $this->successResponse($person, 'Person retrieved successfully');
|
||||
}
|
||||
|
||||
return $this->notFoundResponse('Person not found');
|
||||
} catch (Exception $e) {
|
||||
return $this->errorResponse('Failed to retrieve person', $e);
|
||||
}
|
||||
}
|
||||
|
||||
public function store(StorePersonRequest $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$data = $request->only([
|
||||
'surname', 'christian_name', 'date_of_birth', 'place_of_birth',
|
||||
'date_of_death', 'occupation', 'additional_notes', 'reference', 'id_card_no'
|
||||
]);
|
||||
$data['full_name'] = trim("{$request->christian_name} {$request->surname}");
|
||||
|
||||
$person = Person::create($data);
|
||||
|
||||
// Handle related data
|
||||
foreach ($this->relations as $relation) {
|
||||
if ($request->has($relation)) {
|
||||
$person->$relation()->create($request->$relation);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle photo uploads
|
||||
$uploadedPhotos = [];
|
||||
if ($request->hasFile('photos')) {
|
||||
$photoController = new PhotoController();
|
||||
$uploadedPhotos = $photoController->handlePhotoUpload(
|
||||
$request->file('photos'),
|
||||
$person->person_id,
|
||||
$request->input('captions', []),
|
||||
$request->input('main_photo_index') // Use main_photo_index consistently
|
||||
);
|
||||
}
|
||||
|
||||
// Load all relations including photos
|
||||
$person->load(array_merge($this->relations, ['photos']));
|
||||
|
||||
return $this->successResponse([
|
||||
'person' => $person,
|
||||
'uploaded_photos' => $uploadedPhotos
|
||||
], 'Person created successfully', 201);
|
||||
} catch (Exception $e) {
|
||||
return $this->errorResponse('Failed to create person', $e);
|
||||
}
|
||||
}
|
||||
|
||||
public function update(UpdatePersonRequest $request, string $id): JsonResponse
|
||||
{
|
||||
try {
|
||||
$person = Person::findOrFail($id);
|
||||
|
||||
$data = $request->only([
|
||||
'surname', 'christian_name', 'date_of_birth', 'place_of_birth',
|
||||
'date_of_death', 'occupation', 'additional_notes', 'reference', 'id_card_no'
|
||||
]);
|
||||
|
||||
if ($request->hasAny(['christian_name', 'surname'])) {
|
||||
$christian = $request->input('christian_name', $person->christian_name);
|
||||
$surname = $request->input('surname', $person->surname);
|
||||
$data['full_name'] = trim("$christian $surname");
|
||||
}
|
||||
|
||||
$person->update($data);
|
||||
|
||||
foreach ($this->relations as $relation) {
|
||||
if (is_array($request->$relation ?? null)) {
|
||||
$person->$relation
|
||||
? $person->$relation->update($request->$relation)
|
||||
: $person->$relation()->create($request->$relation);
|
||||
}
|
||||
}
|
||||
|
||||
// STEP 1: Handle photo removal FIRST
|
||||
$preservedMainPhotoId = null;
|
||||
if ($request->has('remove_photos') && is_array($request->input('remove_photos'))) {
|
||||
$photoIds = $request->input('remove_photos');
|
||||
|
||||
// Get current profile photo BEFORE deletion
|
||||
$currentProfilePhoto = Photo::where('person_id', $person->person_id)
|
||||
->where('is_profile_photo', true)
|
||||
->first();
|
||||
|
||||
// If current profile photo is NOT being deleted, preserve its ID
|
||||
if ($currentProfilePhoto && !in_array($currentProfilePhoto->id, $photoIds)) {
|
||||
$preservedMainPhotoId = $currentProfilePhoto->id;
|
||||
}
|
||||
|
||||
// Delete photos
|
||||
foreach ($photoIds as $photoId) {
|
||||
$photo = Photo::find($photoId);
|
||||
|
||||
if ($photo) {
|
||||
$personId = $photo->person_id;
|
||||
|
||||
// Delete the physical file
|
||||
$path = 'public/photos/' . $personId . '/' . $photo->filename;
|
||||
if (Storage::exists($path)) {
|
||||
Storage::delete($path);
|
||||
}
|
||||
|
||||
// Delete from database
|
||||
$photo->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// STEP 2: Handle existing photo updates (captions only - NO profile photo changes yet)
|
||||
if ($request->has('existing_photos')) {
|
||||
$existingPhotos = $request->input('existing_photos');
|
||||
|
||||
if (is_array($existingPhotos)) {
|
||||
foreach ($existingPhotos as $photoData) {
|
||||
if (isset($photoData['id'])) {
|
||||
$photo = Photo::where('id', $photoData['id'])
|
||||
->where('person_id', $person->person_id)
|
||||
->first();
|
||||
|
||||
if ($photo && isset($photoData['caption'])) {
|
||||
$photo->caption = $photoData['caption'];
|
||||
$photo->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// STEP 3: Handle new photo uploads
|
||||
$uploadedPhotos = [];
|
||||
if ($request->hasFile('photos')) {
|
||||
$photoController = new PhotoController();
|
||||
$uploadedPhotos = $photoController->handlePhotoUpload(
|
||||
$request->file('photos'),
|
||||
$person->person_id,
|
||||
$request->input('captions', []),
|
||||
null // Don't set main photo during upload
|
||||
);
|
||||
}
|
||||
|
||||
// STEP 4: Handle profile photo setting - THIS IS THE CRITICAL PART
|
||||
if ($request->boolean('set_as_profile')) {
|
||||
// Reset ALL photos to not be profile photos first
|
||||
Photo::where('person_id', $person->person_id)
|
||||
->update(['is_profile_photo' => false]);
|
||||
|
||||
if ($request->has('profile_photo_id')) {
|
||||
// Setting an existing photo as profile
|
||||
$photoId = $request->input('profile_photo_id');
|
||||
$photo = Photo::where('id', $photoId)
|
||||
->where('person_id', $person->person_id)
|
||||
->first();
|
||||
|
||||
if ($photo) {
|
||||
$photo->is_profile_photo = true;
|
||||
$photo->save();
|
||||
}
|
||||
} elseif ($request->has('main_photo_index')) {
|
||||
// Setting a newly uploaded photo as profile
|
||||
$mainIndex = (int) $request->input('main_photo_index');
|
||||
|
||||
if (isset($uploadedPhotos[$mainIndex])) {
|
||||
$photoId = $uploadedPhotos[$mainIndex]['id'];
|
||||
$photo = Photo::find($photoId);
|
||||
|
||||
if ($photo) {
|
||||
$photo->is_profile_photo = true;
|
||||
$photo->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($preservedMainPhotoId) {
|
||||
// If we're not explicitly setting a new main photo,
|
||||
// but we preserved an existing one, make sure it stays as main
|
||||
Photo::where('person_id', $person->person_id)
|
||||
->update(['is_profile_photo' => false]);
|
||||
|
||||
$photo = Photo::find($preservedMainPhotoId);
|
||||
if ($photo) {
|
||||
$photo->is_profile_photo = true;
|
||||
$photo->save();
|
||||
}
|
||||
}
|
||||
|
||||
// STEP 5: If no profile photo is set and we have photos, set the first one
|
||||
$hasProfilePhoto = Photo::where('person_id', $person->person_id)
|
||||
->where('is_profile_photo', true)
|
||||
->exists();
|
||||
|
||||
if (!$hasProfilePhoto) {
|
||||
$firstPhoto = Photo::where('person_id', $person->person_id)
|
||||
->orderBy('id')
|
||||
->first();
|
||||
|
||||
if ($firstPhoto) {
|
||||
$firstPhoto->is_profile_photo = true;
|
||||
$firstPhoto->save();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->successResponse([
|
||||
'person' => $person->load(array_merge($this->relations, ['photos'])),
|
||||
'uploaded_photos' => $uploadedPhotos
|
||||
], 'Person updated successfully');
|
||||
|
||||
} catch (Exception $e) {
|
||||
return $this->errorResponse('Failed to update person', $e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Handle photo upload for person creation/update
|
||||
*/
|
||||
private function handlePhotoUpload(Request $request, $personId): array
|
||||
{
|
||||
$uploadedPhotos = [];
|
||||
|
||||
if ($request->hasFile('photos')) {
|
||||
$files = $request->file('photos');
|
||||
$captions = $request->input('captions', []); // Changed from photo_captions
|
||||
$mainPhotoIndex = $request->input('main_photo_index'); // Changed from set_as_profile
|
||||
|
||||
foreach ($files as $index => $file) {
|
||||
// Validate file
|
||||
if (!$file->isValid() || !in_array($file->getMimeType(), ['image/jpeg', 'image/png', 'image/gif', 'image/webp'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Clear existing profile photos if this is the main photo
|
||||
if ($mainPhotoIndex !== null && $index == $mainPhotoIndex) {
|
||||
Photo::where('person_id', $personId)->update(['is_profile_photo' => false]);
|
||||
}
|
||||
|
||||
// Generate a unique filename
|
||||
$extension = $file->getClientOriginalExtension();
|
||||
$filename = Str::uuid() . '.' . $extension;
|
||||
|
||||
// Store the file
|
||||
$path = $file->storeAs('photos/' . $personId, $filename, 'public');
|
||||
|
||||
// Create photo record
|
||||
$photo = new Photo([
|
||||
'person_id' => $personId,
|
||||
'filename' => $filename,
|
||||
'original_filename' => $file->getClientOriginalName(),
|
||||
'file_path' => Storage::url($path),
|
||||
'mime_type' => $file->getMimeType(),
|
||||
'file_size' => $file->getSize() / 1024, // Convert to KB
|
||||
'caption' => $captions[$index] ?? null,
|
||||
'is_profile_photo' => ($mainPhotoIndex !== null && $index == $mainPhotoIndex)
|
||||
]);
|
||||
|
||||
$photo->save();
|
||||
$uploadedPhotos[] = $photo;
|
||||
}
|
||||
}
|
||||
|
||||
return $uploadedPhotos;
|
||||
}
|
||||
|
||||
public function destroy(string $id): JsonResponse
|
||||
{
|
||||
try {
|
||||
$person = Person::with($this->relations)->findOrFail($id);
|
||||
|
||||
foreach ($this->relations as $relation) {
|
||||
$person->$relation?->delete();
|
||||
}
|
||||
|
||||
// Delete associated photos
|
||||
if ($person->photos) {
|
||||
foreach ($person->photos as $photo) {
|
||||
$path = 'public/photos/' . $person->person_id . '/' . $photo->filename;
|
||||
if (Storage::exists($path)) {
|
||||
Storage::delete($path);
|
||||
}
|
||||
$photo->delete();
|
||||
}
|
||||
}
|
||||
|
||||
$person->delete();
|
||||
|
||||
return $this->successResponse(null, 'Person deleted successfully');
|
||||
} catch (Exception $e) {
|
||||
return $this->errorResponse('Failed to delete person', $e);
|
||||
}
|
||||
}
|
||||
|
||||
// Response helpers
|
||||
protected function successResponse($data, string $message, int $status = 200): JsonResponse
|
||||
{
|
||||
return response()->json(['success' => true, 'data' => $data, 'message' => $message], $status);
|
||||
}
|
||||
|
||||
protected function notFoundResponse(string $message): JsonResponse
|
||||
{
|
||||
return response()->json(['success' => false, 'message' => $message], 404);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a photo
|
||||
*/
|
||||
public function deletePhoto(string $photoId): JsonResponse
|
||||
{
|
||||
try {
|
||||
$photo = Photo::findOrFail($photoId);
|
||||
|
||||
// Delete the physical file
|
||||
$path = 'public/photos/' . $photo->person_id . '/' . $photo->filename;
|
||||
if (Storage::exists($path)) {
|
||||
Storage::delete($path);
|
||||
}
|
||||
|
||||
// If this was a profile photo, try to set another one
|
||||
if ($photo->is_profile_photo) {
|
||||
$nextPhoto = Photo::where('person_id', $photo->person_id)
|
||||
->where('id', '!=', $photo->id)
|
||||
->first();
|
||||
|
||||
if ($nextPhoto) {
|
||||
$nextPhoto->is_profile_photo = true;
|
||||
$nextPhoto->save();
|
||||
}
|
||||
}
|
||||
|
||||
// Delete the database record
|
||||
$photo->delete();
|
||||
|
||||
return $this->successResponse(null, 'Photo deleted successfully');
|
||||
} catch (Exception $e) {
|
||||
return $this->errorResponse('Failed to delete photo', $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a photo as the profile photo
|
||||
*/
|
||||
public function setAsProfilePhoto(string $photoId): JsonResponse
|
||||
{
|
||||
try {
|
||||
$photo = Photo::findOrFail($photoId);
|
||||
|
||||
// Clear existing profile photos for this person
|
||||
Photo::where('person_id', $photo->person_id)
|
||||
->update(['is_profile_photo' => false]);
|
||||
|
||||
// Set this photo as profile photo
|
||||
$photo->is_profile_photo = true;
|
||||
$photo->save();
|
||||
|
||||
return $this->successResponse($photo, 'Profile photo set successfully');
|
||||
} catch (Exception $e) {
|
||||
return $this->errorResponse('Failed to set profile photo', $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update photo caption
|
||||
*/
|
||||
public function updatePhotoCaption(Request $request, string $photoId): JsonResponse
|
||||
{
|
||||
try {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'caption' => 'required|string|max:255',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'errors' => $validator->errors()
|
||||
], 422);
|
||||
}
|
||||
|
||||
$photo = Photo::findOrFail($photoId);
|
||||
$photo->caption = $request->input('caption');
|
||||
$photo->save();
|
||||
|
||||
return $this->successResponse($photo, 'Caption updated successfully');
|
||||
} catch (Exception $e) {
|
||||
return $this->errorResponse('Failed to update caption', $e);
|
||||
}
|
||||
}
|
||||
|
||||
protected function errorResponse(string $message, Exception $e): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => $message,
|
||||
'error' => $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,181 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Person;
|
||||
use App\Models\Photo;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class PhotoController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get all photos for a specific person
|
||||
*/
|
||||
public function getPhotos($personId)
|
||||
{
|
||||
$person = Person::findOrFail($personId);
|
||||
$photos = $person->photos()->get();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $photos,
|
||||
'profile_photo' => $person->photos()->where('is_profile_photo', true)->first()
|
||||
]);
|
||||
}
|
||||
|
||||
public function handlePhotoUpload($files, $personId, $captions = [], $mainPhotoIndex = null)
|
||||
{
|
||||
$uploadedPhotos = [];
|
||||
|
||||
foreach ($files as $index => $file) {
|
||||
$extension = $file->getClientOriginalExtension();
|
||||
$filename = Str::uuid() . '.' . $extension;
|
||||
$path = $file->storeAs('photos/' . $personId, $filename, 'public');
|
||||
|
||||
// Clear existing profile photos if this is the main photo
|
||||
if ($mainPhotoIndex !== null && $index == $mainPhotoIndex) {
|
||||
Photo::where('person_id', $personId)->update(['is_profile_photo' => false]);
|
||||
}
|
||||
|
||||
$photo = new Photo([
|
||||
'person_id' => $personId,
|
||||
'filename' => $filename,
|
||||
'original_filename' => $file->getClientOriginalName(),
|
||||
'file_path' => Storage::url($path),
|
||||
'mime_type' => $file->getMimeType(),
|
||||
'file_size' => $file->getSize() / 1024, // KB
|
||||
'caption' => $captions[$index] ?? null,
|
||||
'is_profile_photo' => ($mainPhotoIndex !== null && $index == $mainPhotoIndex)
|
||||
]);
|
||||
|
||||
$photo->save();
|
||||
$uploadedPhotos[] = $photo;
|
||||
}
|
||||
|
||||
return $uploadedPhotos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload photos for a person
|
||||
*/
|
||||
public function upload(Request $request, $personId)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'photos' => 'required|array',
|
||||
'photos.*' => 'required|image|max:10240', // Max 10MB per image
|
||||
'captions' => 'nullable|array',
|
||||
'captions.*' => 'nullable|string|max:255',
|
||||
'main_photo_index' => 'nullable|integer|min:0', // Changed from set_as_profile
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'errors' => $validator->errors()
|
||||
], 422);
|
||||
}
|
||||
|
||||
// Find the person
|
||||
$person = Person::findOrFail($personId);
|
||||
|
||||
// Process each uploaded photo
|
||||
if ($request->hasFile('photos')) {
|
||||
$files = $request->file('photos');
|
||||
$captions = $request->input('captions', []);
|
||||
$mainPhotoIndex = $request->input('main_photo_index');
|
||||
|
||||
$uploadedPhotos = $this->handlePhotoUpload($files, $personId, $captions, $mainPhotoIndex);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Photos uploaded successfully',
|
||||
'data' => $uploadedPhotos ?? []
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a photo as the profile photo
|
||||
*/
|
||||
public function setAsProfilePhoto($photoId)
|
||||
{
|
||||
$photo = Photo::findOrFail($photoId);
|
||||
|
||||
// Clear existing profile photos for this person
|
||||
Photo::where('person_id', $photo->person_id)->update(['is_profile_photo' => false]);
|
||||
|
||||
// Set this photo as profile photo
|
||||
$photo->is_profile_photo = true;
|
||||
$result = $photo->save();
|
||||
|
||||
return response()->json([
|
||||
'success' => $result,
|
||||
'message' => $result ? 'Profile photo set successfully' : 'Failed to set profile photo',
|
||||
'data' => $photo
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update photo caption
|
||||
*/
|
||||
public function updateCaption(Request $request, $photoId)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'caption' => 'required|string|max:255',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'errors' => $validator->errors()
|
||||
], 422);
|
||||
}
|
||||
|
||||
$photo = Photo::findOrFail($photoId);
|
||||
$photo->caption = $request->input('caption');
|
||||
$photo->save();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Caption updated successfully',
|
||||
'data' => $photo
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a photo
|
||||
*/
|
||||
public function delete($photoId)
|
||||
{
|
||||
$photo = Photo::findOrFail($photoId);
|
||||
|
||||
// Delete the physical file
|
||||
$path = 'public/photos/' . $photo->person_id . '/' . $photo->filename;
|
||||
if (Storage::exists($path)) {
|
||||
Storage::delete($path);
|
||||
}
|
||||
|
||||
// If this was a profile photo, try to set another one
|
||||
if ($photo->is_profile_photo) {
|
||||
$nextPhoto = Photo::where('person_id', $photo->person_id)
|
||||
->where('id', '!=', $photo->id)
|
||||
->first();
|
||||
|
||||
if ($nextPhoto) {
|
||||
$nextPhoto->is_profile_photo = true;
|
||||
$nextPhoto->save();
|
||||
}
|
||||
}
|
||||
|
||||
// Delete the database record
|
||||
$photo->delete();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Photo deleted successfully'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StorePersonRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
// Person validation rules
|
||||
'surname' => 'nullable|string|max:100',
|
||||
'christian_name' => 'nullable|string|max:100',
|
||||
'full_name' => 'nullable|string|max:200',
|
||||
'date_of_birth' => 'nullable|date',
|
||||
'place_of_birth' => 'nullable|string|max:100',
|
||||
'date_of_death' => 'nullable|date',
|
||||
'occupation' => 'nullable|string|max:100',
|
||||
'additional_notes' => 'nullable|string',
|
||||
'reference' => 'nullable|string|max:100',
|
||||
'id_card_no' => 'nullable|string|max:50',
|
||||
|
||||
// Migration validation rules
|
||||
'migration' => 'nullable|array',
|
||||
'migration.date_of_arrival_aus' => 'nullable|date',
|
||||
'migration.date_of_arrival_nt' => 'nullable|date',
|
||||
'migration.arrival_period' => 'nullable|string|max:50',
|
||||
'migration.data_source' => 'nullable|string|max:100',
|
||||
|
||||
// Naturalization validation rules
|
||||
'naturalization' => 'nullable|array',
|
||||
'naturalization.date_of_naturalisation' => 'nullable|date',
|
||||
'naturalization.no_of_cert' => 'nullable|string|max:50',
|
||||
'naturalization.issued_at' => 'nullable|string|max:100',
|
||||
|
||||
// Residence validation rules
|
||||
'residence' => 'nullable|array',
|
||||
'residence.darwin' => 'nullable|boolean',
|
||||
'residence.katherine' => 'nullable|boolean',
|
||||
'residence.tennant_creek' => 'nullable|boolean',
|
||||
'residence.alice_springs' => 'nullable|boolean',
|
||||
'residence.home_at_death' => 'nullable|string|max:100',
|
||||
|
||||
// Family validation rules
|
||||
'family' => 'nullable|array',
|
||||
'family.names_of_parents' => 'nullable|string',
|
||||
'family.names_of_children' => 'nullable|string',
|
||||
|
||||
// Internment validation rules
|
||||
'internment' => 'nullable|array',
|
||||
'internment.corps_issued' => 'nullable|string|max:100',
|
||||
'internment.interned_in' => 'nullable|string|max:100',
|
||||
'internment.sent_to' => 'nullable|string|max:100',
|
||||
'internment.internee_occupation' => 'nullable|string|max:100',
|
||||
'internment.internee_address' => 'nullable|string',
|
||||
'internment.cav' => 'nullable|string|max:50',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdatePersonRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
// Person validation rules
|
||||
'surname' => 'nullable|string|max:100',
|
||||
'christian_name' => 'nullable|string|max:100',
|
||||
'full_name' => 'nullable|string|max:200',
|
||||
'date_of_birth' => 'nullable|date',
|
||||
'place_of_birth' => 'nullable|string|max:100',
|
||||
'date_of_death' => 'nullable|date',
|
||||
'occupation' => 'nullable|string|max:100',
|
||||
'additional_notes' => 'nullable|string',
|
||||
'reference' => 'nullable|string|max:100',
|
||||
'id_card_no' => 'nullable|string|max:50',
|
||||
|
||||
// Migration validation rules
|
||||
'migration' => 'nullable|array',
|
||||
'migration.date_of_arrival_aus' => 'nullable|date',
|
||||
'migration.date_of_arrival_nt' => 'nullable|date',
|
||||
'migration.arrival_period' => 'nullable|string|max:50',
|
||||
'migration.data_source' => 'nullable|string|max:100',
|
||||
|
||||
// Naturalization validation rules
|
||||
'naturalization' => 'nullable|array',
|
||||
'naturalization.date_of_naturalisation' => 'nullable|date',
|
||||
'naturalization.no_of_cert' => 'nullable|string|max:50',
|
||||
'naturalization.issued_at' => 'nullable|string|max:100',
|
||||
|
||||
// Residence validation rules
|
||||
'residence' => 'nullable|array',
|
||||
'residence.darwin' => 'nullable|boolean',
|
||||
'residence.katherine' => 'nullable|boolean',
|
||||
'residence.tennant_creek' => 'nullable|boolean',
|
||||
'residence.alice_springs' => 'nullable|boolean',
|
||||
'residence.home_at_death' => 'nullable|string|max:100',
|
||||
|
||||
// Family validation rules
|
||||
'family' => 'nullable|array',
|
||||
'family.names_of_parents' => 'nullable|string',
|
||||
'family.names_of_children' => 'nullable|string',
|
||||
|
||||
// Internment validation rules
|
||||
'internment' => 'nullable|array',
|
||||
'internment.corps_issued' => 'nullable|string|max:100',
|
||||
'internment.interned_in' => 'nullable|string|max:100',
|
||||
'internment.sent_to' => 'nullable|string|max:100',
|
||||
'internment.internee_occupation' => 'nullable|string|max:100',
|
||||
'internment.internee_address' => 'nullable|string',
|
||||
'internment.cav' => 'nullable|string|max:50',
|
||||
|
||||
// Photo validation rules
|
||||
'photos' => 'nullable|array',
|
||||
'photos.*' => 'nullable|file|image|max:10240', // Max 10MB per image
|
||||
'captions' => 'nullable|array',
|
||||
'captions.*' => 'nullable|string|max:255',
|
||||
'main_photo_index' => 'nullable|integer|min:0',
|
||||
'set_as_profile' => 'nullable|boolean',
|
||||
'profile_photo_id' => 'nullable|exists:photos,id',
|
||||
'remove_photos' => 'nullable|array',
|
||||
'remove_photos.*' => 'nullable|exists:photos,id',
|
||||
'existing_photos' => 'nullable|array',
|
||||
'existing_photos.*.id' => 'nullable|exists:photos,id',
|
||||
'existing_photos.*.caption' => 'nullable|string|max:255',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
// app/Models/Activity.php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Spatie\Activitylog\Models\Activity as SpatieActivity;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Activity extends SpatieActivity
|
||||
{
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'causer_id');
|
||||
}
|
||||
|
||||
// Optional: shortcut
|
||||
public function getCauserNameAttribute(): ?string
|
||||
{
|
||||
return $this->user?->name;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Family extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $table = 'family';
|
||||
protected $primaryKey = 'family_id';
|
||||
|
||||
protected $fillable = [
|
||||
'person_id',
|
||||
'names_of_parents',
|
||||
'names_of_children',
|
||||
];
|
||||
|
||||
// Relationship
|
||||
public function person()
|
||||
{
|
||||
return $this->belongsTo(Person::class, 'person_id');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Internment extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $table = 'internment';
|
||||
protected $primaryKey = 'internment_id';
|
||||
|
||||
protected $fillable = [
|
||||
'person_id',
|
||||
'corps_issued',
|
||||
'interned_in',
|
||||
'sent_to',
|
||||
'internee_occupation',
|
||||
'internee_address',
|
||||
'cav',
|
||||
];
|
||||
|
||||
// Relationship
|
||||
public function person()
|
||||
{
|
||||
return $this->belongsTo(Person::class, 'person_id');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Migration extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $table = 'migration';
|
||||
protected $primaryKey = 'migration_id';
|
||||
|
||||
protected $fillable = [
|
||||
'person_id',
|
||||
'date_of_arrival_aus',
|
||||
'date_of_arrival_nt',
|
||||
'arrival_period',
|
||||
'data_source',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'date_of_arrival_aus' => 'date',
|
||||
'date_of_arrival_nt' => 'date',
|
||||
];
|
||||
|
||||
// Relationship
|
||||
public function person()
|
||||
{
|
||||
return $this->belongsTo(Person::class, 'person_id');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Naturalization extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $table = 'naturalization';
|
||||
protected $primaryKey = 'naturalization_id';
|
||||
|
||||
protected $fillable = [
|
||||
'person_id',
|
||||
'date_of_naturalisation',
|
||||
'no_of_cert',
|
||||
'issued_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'date_of_naturalisation' => 'date',
|
||||
];
|
||||
|
||||
// Relationship
|
||||
public function person()
|
||||
{
|
||||
return $this->belongsTo(Person::class, 'person_id');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Laravel\Scout\Searchable;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
|
||||
class Person extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes, LogsActivity;
|
||||
|
||||
protected $table = 'person';
|
||||
protected $primaryKey = 'person_id';
|
||||
|
||||
protected $fillable = [
|
||||
'surname',
|
||||
'christian_name',
|
||||
'full_name',
|
||||
'date_of_birth',
|
||||
'place_of_birth',
|
||||
'date_of_death',
|
||||
'occupation',
|
||||
'additional_notes',
|
||||
'reference',
|
||||
'id_card_no',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'date_of_birth' => 'date',
|
||||
'date_of_death' => 'date',
|
||||
];
|
||||
|
||||
// 🔧 Configure Spatie logging
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->useLogName('person')
|
||||
->logFillable()
|
||||
->logOnlyDirty();
|
||||
}
|
||||
|
||||
// 📝 Custom activity description for events
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
return match ($eventName) {
|
||||
'created' => 'Added new migrant',
|
||||
'updated' => 'Updated migrant details',
|
||||
'deleted' => 'Deleted migrant record',
|
||||
default => ucfirst($eventName) . ' migrant record',
|
||||
};
|
||||
}
|
||||
|
||||
// 🔗 Relationships
|
||||
public function migration()
|
||||
{
|
||||
return $this->hasOne(Migration::class, 'person_id');
|
||||
}
|
||||
|
||||
public function naturalization()
|
||||
{
|
||||
return $this->hasOne(Naturalization::class, 'person_id');
|
||||
}
|
||||
|
||||
public function residence()
|
||||
{
|
||||
return $this->hasOne(Residence::class, 'person_id');
|
||||
}
|
||||
|
||||
public function family()
|
||||
{
|
||||
return $this->hasOne(Family::class, 'person_id');
|
||||
}
|
||||
|
||||
public function internment()
|
||||
{
|
||||
return $this->hasOne(Internment::class, 'person_id');
|
||||
}
|
||||
|
||||
public function photos()
|
||||
{
|
||||
return $this->hasMany(Photo::class, 'person_id', 'person_id');
|
||||
}
|
||||
|
||||
public function profilePhoto()
|
||||
{
|
||||
return $this->hasMany(Photo::class, 'person_id', 'person_id')
|
||||
->where('is_profile_photo', true)
|
||||
->latest()
|
||||
->first();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
|
||||
class Photo extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes, LogsActivity;
|
||||
|
||||
protected $fillable = [
|
||||
'person_id',
|
||||
'filename',
|
||||
'original_filename',
|
||||
'file_path',
|
||||
'mime_type',
|
||||
'file_size',
|
||||
'is_profile_photo',
|
||||
'caption',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_profile_photo' => 'boolean',
|
||||
];
|
||||
|
||||
// 🔧 Configure Spatie logging
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->useLogName('photo')
|
||||
->logFillable()
|
||||
->logOnlyDirty();
|
||||
}
|
||||
|
||||
// 📝 Custom activity description for events
|
||||
public function getDescriptionForEvent(string $eventName): string
|
||||
{
|
||||
return match ($eventName) {
|
||||
'created' => 'Added new photo',
|
||||
'updated' => 'Updated photo details',
|
||||
'deleted' => 'Deleted photo',
|
||||
default => ucfirst($eventName) . ' photo record',
|
||||
};
|
||||
}
|
||||
|
||||
// 🔗 Relationships
|
||||
public function person()
|
||||
{
|
||||
return $this->belongsTo(Person::class, 'person_id', 'person_id');
|
||||
}
|
||||
|
||||
// Helper method to set a photo as profile photo
|
||||
public function setAsProfilePhoto(): bool
|
||||
{
|
||||
// First unset any existing profile photo for this person
|
||||
if ($this->person_id) {
|
||||
self::where('person_id', $this->person_id)
|
||||
->where('is_profile_photo', true)
|
||||
->update(['is_profile_photo' => false]);
|
||||
}
|
||||
|
||||
// Set this photo as profile photo
|
||||
$this->is_profile_photo = true;
|
||||
return $this->save();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Residence extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $table = 'residence';
|
||||
protected $primaryKey = 'residence_id';
|
||||
|
||||
protected $fillable = [
|
||||
'person_id',
|
||||
'town_or_city',
|
||||
'home_at_death',
|
||||
];
|
||||
|
||||
protected $casts = [];
|
||||
|
||||
// Relationship
|
||||
public function person()
|
||||
{
|
||||
return $this->belongsTo(Person::class, 'person_id');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, HasFactory, Notifiable, LogsActivity;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'is_admin',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
// ✅ Required by LogsActivity
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->useLogName('user')
|
||||
->logOnly(['name', 'email', 'is_admin']) // specify what to track
|
||||
->logOnlyDirty(); // only log changes
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Activity::saving(function ($activity) {
|
||||
if (auth()->check()) {
|
||||
$activity->causer_name = auth()->user()->name;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The path to your application's "home" route.
|
||||
*
|
||||
* Typically, users are redirected here after authentication.
|
||||
*/
|
||||
public const HOME = '/dashboard';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, and other route configuration.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
|
||||
$this->routes(function () {
|
||||
Route::middleware('api')
|
||||
->prefix('api')
|
||||
->group(base_path('routes/api.php'));
|
||||
|
||||
Route::middleware('web')
|
||||
->group(base_path('routes/web.php'));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
// Register the Composer autoloader...
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
// Bootstrap Laravel and handle the command...
|
||||
/** @var Application $app */
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
|
||||
$status = $app->handleCommand(new ArgvInput);
|
||||
|
||||
exit($status);
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Foundation\Configuration\Exceptions;
|
||||
use Illuminate\Foundation\Configuration\Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Illuminate\Http\Middleware\HandleCors;
|
||||
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
web: __DIR__.'/../routes/web.php',
|
||||
api: __DIR__.'/../routes/api.php',
|
||||
commands: __DIR__.'/../routes/console.php',
|
||||
health: '/up',
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware) {
|
||||
// Global CORS
|
||||
$middleware->web(prepend: [
|
||||
\Illuminate\Http\Middleware\HandleCors::class,
|
||||
]);
|
||||
|
||||
$middleware->api(prepend: [
|
||||
\Illuminate\Http\Middleware\HandleCors::class,
|
||||
]);
|
||||
|
||||
$middleware->api(append: [
|
||||
\Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
]);
|
||||
|
||||
$middleware->alias([
|
||||
'auth:sanctum' => \Laravel\Sanctum\Http\Middleware\Authenticate::class,
|
||||
]);
|
||||
})
|
||||
|
||||
->withExceptions(function (Exceptions $exceptions) {
|
||||
$exceptions->renderable(function (\Illuminate\Auth\AuthenticationException $e, Request $request) {
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Unauthenticated.'
|
||||
], 401);
|
||||
}
|
||||
});
|
||||
})->create();
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
App\Providers\AppServiceProvider::class,
|
||||
];
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
{
|
||||
"$schema": "https://getcomposer.org/schema.json",
|
||||
"name": "laravel/laravel",
|
||||
"type": "project",
|
||||
"description": "The skeleton application for the Laravel framework.",
|
||||
"keywords": ["laravel", "framework"],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.2",
|
||||
"artesaos/seotools": "^1.3",
|
||||
"laravel/framework": "^12.0",
|
||||
"laravel/sanctum": "^4.1",
|
||||
"laravel/scout": "^10.15",
|
||||
"laravel/tinker": "^2.10.1",
|
||||
"protonemedia/laravel-cross-eloquent-search": "^3.6",
|
||||
"spatie/laravel-activitylog": "^4.10",
|
||||
"spatie/laravel-query-builder": "^6.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.23",
|
||||
"laravel/pail": "^1.2.2",
|
||||
"laravel/pint": "^1.13",
|
||||
"laravel/sail": "^1.41",
|
||||
"mockery/mockery": "^1.6",
|
||||
"nunomaduro/collision": "^8.6",
|
||||
"phpunit/phpunit": "^11.5.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||
"@php artisan package:discover --ansi"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
|
||||
],
|
||||
"post-root-package-install": [
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||
],
|
||||
"post-create-project-cmd": [
|
||||
"@php artisan key:generate --ansi",
|
||||
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
|
||||
"@php artisan migrate --graceful --ansi"
|
||||
],
|
||||
"dev": [
|
||||
"Composer\\Config::disableProcessTimeout",
|
||||
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite"
|
||||
],
|
||||
"test": [
|
||||
"@php artisan config:clear --ansi",
|
||||
"@php artisan test"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"dont-discover": []
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"pestphp/pest-plugin": true,
|
||||
"php-http/discovery": true
|
||||
}
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"prefer-stable": true
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
* If set to false, no activities will be saved to the database.
|
||||
*/
|
||||
'enabled' => env('ACTIVITY_LOGGER_ENABLED', true),
|
||||
|
||||
/*
|
||||
* When the clean-command is executed, all recording activities older than
|
||||
* the number of days specified here will be deleted.
|
||||
*/
|
||||
'delete_records_older_than_days' => 365,
|
||||
|
||||
/*
|
||||
* If no log name is passed to the activity() helper
|
||||
* we use this default log name.
|
||||
*/
|
||||
'default_log_name' => 'default',
|
||||
|
||||
/*
|
||||
* You can specify an auth driver here that gets user models.
|
||||
* If this is null we'll use the current Laravel auth driver.
|
||||
*/
|
||||
'default_auth_driver' => null,
|
||||
|
||||
/*
|
||||
* If set to true, the subject returns soft deleted models.
|
||||
*/
|
||||
'subject_returns_soft_deleted_models' => false,
|
||||
|
||||
/*
|
||||
* This model will be used to log activity.
|
||||
* It should implement the Spatie\Activitylog\Contracts\Activity interface
|
||||
* and extend Illuminate\Database\Eloquent\Model.
|
||||
*/
|
||||
'activity_model' => \Spatie\Activitylog\Models\Activity::class,
|
||||
|
||||
/*
|
||||
* This is the name of the table that will be created by the migration and
|
||||
* used by the Activity model shipped with this package.
|
||||
*/
|
||||
'table_name' => env('ACTIVITY_LOGGER_TABLE_NAME', 'activity_log'),
|
||||
|
||||
/*
|
||||
* This is the database connection that will be used by the migration and
|
||||
* the Activity model shipped with this package. In case it's not set
|
||||
* Laravel's database.default will be used instead.
|
||||
*/
|
||||
'database_connection' => env('ACTIVITY_LOGGER_DB_CONNECTION'),
|
||||
];
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value is the name of your application, which will be used when the
|
||||
| framework needs to place the application's name in a notification or
|
||||
| other UI elements where an application name needs to be displayed.
|
||||
|
|
||||
*/
|
||||
|
||||
'name' => env('APP_NAME', 'Laravel'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Environment
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the "environment" your application is currently
|
||||
| running in. This may determine how you prefer to configure various
|
||||
| services the application utilizes. Set this in your ".env" file.
|
||||
|
|
||||
*/
|
||||
|
||||
'env' => env('APP_ENV', 'production'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Debug Mode
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When your application is in debug mode, detailed error messages with
|
||||
| stack traces will be shown on every error that occurs within your
|
||||
| application. If disabled, a simple generic error page is shown.
|
||||
|
|
||||
*/
|
||||
|
||||
'debug' => (bool) env('APP_DEBUG', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application URL
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This URL is used by the console to properly generate URLs when using
|
||||
| the Artisan command line tool. You should set this to the root of
|
||||
| the application so that it's available within Artisan commands.
|
||||
|
|
||||
*/
|
||||
|
||||
'url' => env('APP_URL', 'http://localhost'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Timezone
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default timezone for your application, which
|
||||
| will be used by the PHP date and date-time functions. The timezone
|
||||
| is set to "UTC" by default as it is suitable for most use cases.
|
||||
|
|
||||
*/
|
||||
|
||||
'timezone' => 'UTC',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Locale Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The application locale determines the default locale that will be used
|
||||
| by Laravel's translation / localization methods. This option can be
|
||||
| set to any locale for which you plan to have translation strings.
|
||||
|
|
||||
*/
|
||||
|
||||
'locale' => env('APP_LOCALE', 'en'),
|
||||
|
||||
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
|
||||
|
||||
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This key is utilized by Laravel's encryption services and should be set
|
||||
| to a random, 32 character string to ensure that all encrypted values
|
||||
| are secure. You should do this prior to deploying the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'cipher' => 'AES-256-CBC',
|
||||
|
||||
'key' => env('APP_KEY'),
|
||||
|
||||
'previous_keys' => [
|
||||
...array_filter(
|
||||
explode(',', env('APP_PREVIOUS_KEYS', ''))
|
||||
),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Maintenance Mode Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options determine the driver used to determine and
|
||||
| manage Laravel's "maintenance mode" status. The "cache" driver will
|
||||
| allow maintenance mode to be controlled across multiple machines.
|
||||
|
|
||||
| Supported drivers: "file", "cache"
|
||||
|
|
||||
*/
|
||||
|
||||
'maintenance' => [
|
||||
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
|
||||
'store' => env('APP_MAINTENANCE_STORE', 'database'),
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Defaults
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default authentication "guard" and password
|
||||
| reset "broker" for your application. You may change these values
|
||||
| as required, but they're a perfect start for most applications.
|
||||
|
|
||||
*/
|
||||
|
||||
'defaults' => [
|
||||
'guard' => env('AUTH_GUARD', 'web'),
|
||||
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Guards
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Next, you may define every authentication guard for your application.
|
||||
| Of course, a great default configuration has been defined for you
|
||||
| which utilizes session storage plus the Eloquent user provider.
|
||||
|
|
||||
| All authentication guards have a user provider, which defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| system used by the application. Typically, Eloquent is utilized.
|
||||
|
|
||||
| Supported: "session"
|
||||
|
|
||||
*/
|
||||
|
||||
'guards' => [
|
||||
'web' => [
|
||||
'driver' => 'session',
|
||||
'provider' => 'users',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| User Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| All authentication guards have a user provider, which defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| system used by the application. Typically, Eloquent is utilized.
|
||||
|
|
||||
| If you have multiple user tables or models you may configure multiple
|
||||
| providers to represent the model / table. These providers may then
|
||||
| be assigned to any extra authentication guards you have defined.
|
||||
|
|
||||
| Supported: "database", "eloquent"
|
||||
|
|
||||
*/
|
||||
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => env('AUTH_MODEL', App\Models\User::class),
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
// 'driver' => 'database',
|
||||
// 'table' => 'users',
|
||||
// ],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Resetting Passwords
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options specify the behavior of Laravel's password
|
||||
| reset functionality, including the table utilized for token storage
|
||||
| and the user provider that is invoked to actually retrieve users.
|
||||
|
|
||||
| The expiry time is the number of minutes that each reset token will be
|
||||
| considered valid. This security feature keeps tokens short-lived so
|
||||
| they have less time to be guessed. You may change this as needed.
|
||||
|
|
||||
| The throttle setting is the number of seconds a user must wait before
|
||||
| generating more password reset tokens. This prevents the user from
|
||||
| quickly generating a very large amount of password reset tokens.
|
||||
|
|
||||
*/
|
||||
|
||||
'passwords' => [
|
||||
'users' => [
|
||||
'provider' => 'users',
|
||||
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
|
||||
'expire' => 60,
|
||||
'throttle' => 60,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Confirmation Timeout
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define the amount of seconds before a password confirmation
|
||||
| window expires and users are asked to re-enter their password via the
|
||||
| confirmation screen. By default, the timeout lasts for three hours.
|
||||
|
|
||||
*/
|
||||
|
||||
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default cache store that will be used by the
|
||||
| framework. This connection is utilized if another isn't explicitly
|
||||
| specified when running a cache operation inside the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('CACHE_STORE', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Stores
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of the cache "stores" for your application as
|
||||
| well as their drivers. You may even define multiple stores for the
|
||||
| same cache driver to group types of items stored in your caches.
|
||||
|
|
||||
| Supported drivers: "array", "database", "file", "memcached",
|
||||
| "redis", "dynamodb", "octane", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'stores' => [
|
||||
|
||||
'array' => [
|
||||
'driver' => 'array',
|
||||
'serialize' => false,
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'connection' => env('DB_CACHE_CONNECTION'),
|
||||
'table' => env('DB_CACHE_TABLE', 'cache'),
|
||||
'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
|
||||
'lock_table' => env('DB_CACHE_LOCK_TABLE'),
|
||||
],
|
||||
|
||||
'file' => [
|
||||
'driver' => 'file',
|
||||
'path' => storage_path('framework/cache/data'),
|
||||
'lock_path' => storage_path('framework/cache/data'),
|
||||
],
|
||||
|
||||
'memcached' => [
|
||||
'driver' => 'memcached',
|
||||
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
|
||||
'sasl' => [
|
||||
env('MEMCACHED_USERNAME'),
|
||||
env('MEMCACHED_PASSWORD'),
|
||||
],
|
||||
'options' => [
|
||||
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
|
||||
],
|
||||
'servers' => [
|
||||
[
|
||||
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
|
||||
'port' => env('MEMCACHED_PORT', 11211),
|
||||
'weight' => 100,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => env('REDIS_CACHE_CONNECTION', 'cache'),
|
||||
'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'),
|
||||
],
|
||||
|
||||
'dynamodb' => [
|
||||
'driver' => 'dynamodb',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
|
||||
'endpoint' => env('DYNAMODB_ENDPOINT'),
|
||||
],
|
||||
|
||||
'octane' => [
|
||||
'driver' => 'octane',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Key Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the APC, database, memcached, Redis, and DynamoDB cache
|
||||
| stores, there might be other applications using the same cache. For
|
||||
| that reason, you may prefix every cache key to avoid collisions.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'paths' => ['api/*', 'sanctum/csrf-cookie'],
|
||||
'allowed_methods' => ['*'],
|
||||
'allowed_origins' => [
|
||||
'http://localhost:5173',
|
||||
'http://127.0.0.1:5173',
|
||||
'http://192.168.1.58:3000',
|
||||
'https://your-production-site.com',
|
||||
],
|
||||
'allowed_origins_patterns' => [],
|
||||
'allowed_headers' => ['*'],
|
||||
'exposed_headers' => [],
|
||||
'max_age' => 0,
|
||||
'supports_credentials' => true,
|
||||
];
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Database Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which of the database connections below you wish
|
||||
| to use as your default connection for database operations. This is
|
||||
| the connection which will be utilized unless another connection
|
||||
| is explicitly specified when you execute a query / statement.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('DB_CONNECTION', 'sqlite'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Database Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Below are all of the database connections defined for your application.
|
||||
| An example configuration is provided for each database system which
|
||||
| is supported by Laravel. You're free to add / remove connections.
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sqlite' => [
|
||||
'driver' => 'sqlite',
|
||||
'url' => env('DB_URL'),
|
||||
'database' => env('DB_DATABASE', database_path('database.sqlite')),
|
||||
'prefix' => '',
|
||||
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
|
||||
'busy_timeout' => null,
|
||||
'journal_mode' => null,
|
||||
'synchronous' => null,
|
||||
],
|
||||
|
||||
'mysql' => [
|
||||
'driver' => 'mysql',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'mariadb' => [
|
||||
'driver' => 'mariadb',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'pgsql' => [
|
||||
'driver' => 'pgsql',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '5432'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'search_path' => 'public',
|
||||
'sslmode' => 'prefer',
|
||||
],
|
||||
|
||||
'sqlsrv' => [
|
||||
'driver' => 'sqlsrv',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
'port' => env('DB_PORT', '1433'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
|
||||
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Migration Repository Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This table keeps track of all the migrations that have already run for
|
||||
| your application. Using this information, we can determine which of
|
||||
| the migrations on disk haven't actually been run on the database.
|
||||
|
|
||||
*/
|
||||
|
||||
'migrations' => [
|
||||
'table' => 'migrations',
|
||||
'update_date_on_publish' => true,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Redis Databases
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Redis is an open source, fast, and advanced key-value store that also
|
||||
| provides a richer body of commands than a typical key-value system
|
||||
| such as Memcached. You may define your connection settings here.
|
||||
|
|
||||
*/
|
||||
|
||||
'redis' => [
|
||||
|
||||
'client' => env('REDIS_CLIENT', 'phpredis'),
|
||||
|
||||
'options' => [
|
||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
|
||||
'persistent' => env('REDIS_PERSISTENT', false),
|
||||
],
|
||||
|
||||
'default' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_DB', '0'),
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_CACHE_DB', '1'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Filesystem Disk
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default filesystem disk that should be used
|
||||
| by the framework. The "local" disk, as well as a variety of cloud
|
||||
| based disks are available to your application for file storage.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('FILESYSTEM_DISK', 'local'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Filesystem Disks
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Below you may configure as many filesystem disks as necessary, and you
|
||||
| may even configure multiple disks for the same driver. Examples for
|
||||
| most supported storage drivers are configured here for reference.
|
||||
|
|
||||
| Supported drivers: "local", "ftp", "sftp", "s3"
|
||||
|
|
||||
*/
|
||||
|
||||
'disks' => [
|
||||
|
||||
'local' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/private'),
|
||||
'serve' => true,
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
'public' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/public'),
|
||||
'url' => env('APP_URL').'/storage',
|
||||
'visibility' => 'public',
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
's3' => [
|
||||
'driver' => 's3',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION'),
|
||||
'bucket' => env('AWS_BUCKET'),
|
||||
'url' => env('AWS_URL'),
|
||||
'endpoint' => env('AWS_ENDPOINT'),
|
||||
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Symbolic Links
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the symbolic links that will be created when the
|
||||
| `storage:link` Artisan command is executed. The array keys should be
|
||||
| the locations of the links and the values should be their targets.
|
||||
|
|
||||
*/
|
||||
|
||||
'links' => [
|
||||
public_path('storage') => storage_path('app/public'),
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
<?php
|
||||
|
||||
use Monolog\Handler\NullHandler;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Handler\SyslogUdpHandler;
|
||||
use Monolog\Processor\PsrLogMessageProcessor;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default log channel that is utilized to write
|
||||
| messages to your logs. The value provided here should match one of
|
||||
| the channels present in the list of "channels" configured below.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('LOG_CHANNEL', 'stack'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Deprecations Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the log channel that should be used to log warnings
|
||||
| regarding deprecated PHP and library features. This allows you to get
|
||||
| your application ready for upcoming major versions of dependencies.
|
||||
|
|
||||
*/
|
||||
|
||||
'deprecations' => [
|
||||
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
|
||||
'trace' => env('LOG_DEPRECATIONS_TRACE', false),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Log Channels
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the log channels for your application. Laravel
|
||||
| utilizes the Monolog PHP logging library, which includes a variety
|
||||
| of powerful log handlers and formatters that you're free to use.
|
||||
|
|
||||
| Available drivers: "single", "daily", "slack", "syslog",
|
||||
| "errorlog", "monolog", "custom", "stack"
|
||||
|
|
||||
*/
|
||||
|
||||
'channels' => [
|
||||
|
||||
'stack' => [
|
||||
'driver' => 'stack',
|
||||
'channels' => explode(',', env('LOG_STACK', 'single')),
|
||||
'ignore_exceptions' => false,
|
||||
],
|
||||
|
||||
'single' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'daily' => [
|
||||
'driver' => 'daily',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'days' => env('LOG_DAILY_DAYS', 14),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'driver' => 'slack',
|
||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||
'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'),
|
||||
'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
|
||||
'level' => env('LOG_LEVEL', 'critical'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'papertrail' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
|
||||
'handler_with' => [
|
||||
'host' => env('PAPERTRAIL_URL'),
|
||||
'port' => env('PAPERTRAIL_PORT'),
|
||||
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
|
||||
],
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'stderr' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => StreamHandler::class,
|
||||
'handler_with' => [
|
||||
'stream' => 'php://stderr',
|
||||
],
|
||||
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'syslog' => [
|
||||
'driver' => 'syslog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'errorlog' => [
|
||||
'driver' => 'errorlog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'null' => [
|
||||
'driver' => 'monolog',
|
||||
'handler' => NullHandler::class,
|
||||
],
|
||||
|
||||
'emergency' => [
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Mailer
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default mailer that is used to send all email
|
||||
| messages unless another mailer is explicitly specified when sending
|
||||
| the message. All additional mailers can be configured within the
|
||||
| "mailers" array. Examples of each type of mailer are provided.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('MAIL_MAILER', 'log'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Mailer Configurations
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure all of the mailers used by your application plus
|
||||
| their respective settings. Several examples have been configured for
|
||||
| you and you are free to add your own as your application requires.
|
||||
|
|
||||
| Laravel supports a variety of mail "transport" drivers that can be used
|
||||
| when delivering an email. You may specify which one you're using for
|
||||
| your mailers below. You may also add additional mailers if needed.
|
||||
|
|
||||
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
|
||||
| "postmark", "resend", "log", "array",
|
||||
| "failover", "roundrobin"
|
||||
|
|
||||
*/
|
||||
|
||||
'mailers' => [
|
||||
|
||||
'smtp' => [
|
||||
'transport' => 'smtp',
|
||||
'scheme' => env('MAIL_SCHEME'),
|
||||
'url' => env('MAIL_URL'),
|
||||
'host' => env('MAIL_HOST', '127.0.0.1'),
|
||||
'port' => env('MAIL_PORT', 2525),
|
||||
'username' => env('MAIL_USERNAME'),
|
||||
'password' => env('MAIL_PASSWORD'),
|
||||
'timeout' => null,
|
||||
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url(env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'transport' => 'ses',
|
||||
],
|
||||
|
||||
'postmark' => [
|
||||
'transport' => 'postmark',
|
||||
// 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'),
|
||||
// 'client' => [
|
||||
// 'timeout' => 5,
|
||||
// ],
|
||||
],
|
||||
|
||||
'resend' => [
|
||||
'transport' => 'resend',
|
||||
],
|
||||
|
||||
'sendmail' => [
|
||||
'transport' => 'sendmail',
|
||||
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
|
||||
],
|
||||
|
||||
'log' => [
|
||||
'transport' => 'log',
|
||||
'channel' => env('MAIL_LOG_CHANNEL'),
|
||||
],
|
||||
|
||||
'array' => [
|
||||
'transport' => 'array',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'transport' => 'failover',
|
||||
'mailers' => [
|
||||
'smtp',
|
||||
'log',
|
||||
],
|
||||
'retry_after' => 60,
|
||||
],
|
||||
|
||||
'roundrobin' => [
|
||||
'transport' => 'roundrobin',
|
||||
'mailers' => [
|
||||
'ses',
|
||||
'postmark',
|
||||
],
|
||||
'retry_after' => 60,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Global "From" Address
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You may wish for all emails sent by your application to be sent from
|
||||
| the same address. Here you may specify a name and address that is
|
||||
| used globally for all emails that are sent by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'from' => [
|
||||
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
||||
'name' => env('MAIL_FROM_NAME', 'Example'),
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Queue Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Laravel's queue supports a variety of backends via a single, unified
|
||||
| API, giving you convenient access to each backend using identical
|
||||
| syntax for each. The default queue connection is defined below.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('QUEUE_CONNECTION', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queue Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the connection options for every queue backend
|
||||
| used by your application. An example configuration is provided for
|
||||
| each backend supported by Laravel. You're also free to add more.
|
||||
|
|
||||
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sync' => [
|
||||
'driver' => 'sync',
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'connection' => env('DB_QUEUE_CONNECTION'),
|
||||
'table' => env('DB_QUEUE_TABLE', 'jobs'),
|
||||
'queue' => env('DB_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'beanstalkd' => [
|
||||
'driver' => 'beanstalkd',
|
||||
'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
|
||||
'queue' => env('BEANSTALKD_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90),
|
||||
'block_for' => 0,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'sqs' => [
|
||||
'driver' => 'sqs',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
|
||||
'queue' => env('SQS_QUEUE', 'default'),
|
||||
'suffix' => env('SQS_SUFFIX'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => env('REDIS_QUEUE_CONNECTION', 'default'),
|
||||
'queue' => env('REDIS_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90),
|
||||
'block_for' => null,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Job Batching
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following options configure the database and table that store job
|
||||
| batching information. These options can be updated to any database
|
||||
| connection and table which has been defined by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'batching' => [
|
||||
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||
'table' => 'job_batches',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Failed Queue Jobs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These options configure the behavior of failed queue job logging so you
|
||||
| can control how and where failed jobs are stored. Laravel ships with
|
||||
| support for storing failed jobs in a simple file or in a database.
|
||||
|
|
||||
| Supported drivers: "database-uuids", "dynamodb", "file", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'failed' => [
|
||||
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
|
||||
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||
'table' => 'failed_jobs',
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Stateful Domains
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Requests from the following domains / hosts will receive stateful API
|
||||
| authentication cookies. Typically, these should include your local
|
||||
| and production domains which access your API via a frontend SPA.
|
||||
|
|
||||
*/
|
||||
|
||||
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
|
||||
'%s,%s',
|
||||
'localhost,localhost:3000,localhost:8000,127.0.0.1,127.0.0.1:8000,::1',
|
||||
'migrants.staging.anss.au'
|
||||
))),
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Sanctum Guards
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This array contains the authentication guards that will be checked when
|
||||
| Sanctum is trying to authenticate a request. If none of these guards
|
||||
| are able to authenticate the request, Sanctum will use the bearer
|
||||
| token that's present on an incoming request for authentication.
|
||||
|
|
||||
*/
|
||||
|
||||
'guard' => ['web'],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Expiration Minutes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value controls the number of minutes until an issued token will be
|
||||
| considered expired. This will override any values set in the token's
|
||||
| "expires_at" attribute, but first-party sessions are not affected.
|
||||
|
|
||||
*/
|
||||
|
||||
'expiration' => null,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Token Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Sanctum can prefix new tokens in order to take advantage of numerous
|
||||
| security scanning initiatives maintained by open source platforms
|
||||
| that notify developers if they commit tokens into repositories.
|
||||
|
|
||||
| See: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning
|
||||
|
|
||||
*/
|
||||
|
||||
'token_prefix' => env('SANCTUM_TOKEN_PREFIX', ''),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Sanctum Middleware
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When authenticating your first-party SPA with Sanctum you may need to
|
||||
| customize some of the middleware Sanctum uses while processing the
|
||||
| request. You may change the middleware listed below as required.
|
||||
|
|
||||
*/
|
||||
|
||||
'middleware' => [
|
||||
'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class,
|
||||
'encrypt_cookies' => Illuminate\Cookie\Middleware\EncryptCookies::class,
|
||||
'validate_csrf_token' => Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class,
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,209 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Search Engine
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default search connection that gets used while
|
||||
| using Laravel Scout. This connection is used when syncing all models
|
||||
| to the search service. You should adjust this based on your needs.
|
||||
|
|
||||
| Supported: "algolia", "meilisearch", "typesense",
|
||||
| "database", "collection", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => env('SCOUT_DRIVER', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Index Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify a prefix that will be applied to all search index
|
||||
| names used by Scout. This prefix may be useful if you have multiple
|
||||
| "tenants" or applications sharing the same search infrastructure.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('SCOUT_PREFIX', ''),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queue Data Syncing
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to control if the operations that sync your data
|
||||
| with your search engines are queued. When this is set to "true" then
|
||||
| all automatic data syncing will get queued for better performance.
|
||||
|
|
||||
*/
|
||||
|
||||
'queue' => env('SCOUT_QUEUE', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Database Transactions
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This configuration option determines if your data will only be synced
|
||||
| with your search indexes after every open database transaction has
|
||||
| been committed, thus preventing any discarded data from syncing.
|
||||
|
|
||||
*/
|
||||
|
||||
'after_commit' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Chunk Sizes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These options allow you to control the maximum chunk size when you are
|
||||
| mass importing data into the search engine. This allows you to fine
|
||||
| tune each of these chunk sizes based on the power of the servers.
|
||||
|
|
||||
*/
|
||||
|
||||
'chunk' => [
|
||||
'searchable' => 500,
|
||||
'unsearchable' => 500,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Soft Deletes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows to control whether to keep soft deleted records in
|
||||
| the search indexes. Maintaining soft deleted records can be useful
|
||||
| if your application still needs to search for the records later.
|
||||
|
|
||||
*/
|
||||
|
||||
'soft_delete' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Identify User
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to control whether to notify the search engine
|
||||
| of the user performing the search. This is sometimes useful if the
|
||||
| engine supports any analytics based on this application's users.
|
||||
|
|
||||
| Supported engines: "algolia"
|
||||
|
|
||||
*/
|
||||
|
||||
'identify' => env('SCOUT_IDENTIFY', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Algolia Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure your Algolia settings. Algolia is a cloud hosted
|
||||
| search engine which works great with Scout out of the box. Just plug
|
||||
| in your application ID and admin API key to get started searching.
|
||||
|
|
||||
*/
|
||||
|
||||
'algolia' => [
|
||||
'id' => env('ALGOLIA_APP_ID', ''),
|
||||
'secret' => env('ALGOLIA_SECRET', ''),
|
||||
'index-settings' => [
|
||||
// 'users' => [
|
||||
// 'searchableAttributes' => ['id', 'name', 'email'],
|
||||
// 'attributesForFaceting'=> ['filterOnly(email)'],
|
||||
// ],
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Meilisearch Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure your Meilisearch settings. Meilisearch is an open
|
||||
| source search engine with minimal configuration. Below, you can state
|
||||
| the host and key information for your own Meilisearch installation.
|
||||
|
|
||||
| See: https://www.meilisearch.com/docs/learn/configuration/instance_options#all-instance-options
|
||||
|
|
||||
*/
|
||||
|
||||
'meilisearch' => [
|
||||
'host' => env('MEILISEARCH_HOST', 'http://localhost:7700'),
|
||||
'key' => env('MEILISEARCH_KEY'),
|
||||
'index-settings' => [
|
||||
// 'users' => [
|
||||
// 'filterableAttributes'=> ['id', 'name', 'email'],
|
||||
// ],
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Typesense Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure your Typesense settings. Typesense is an open
|
||||
| source search engine using minimal configuration. Below, you will
|
||||
| state the host, key, and schema configuration for the instance.
|
||||
|
|
||||
*/
|
||||
|
||||
'typesense' => [
|
||||
'client-settings' => [
|
||||
'api_key' => env('TYPESENSE_API_KEY', 'xyz'),
|
||||
'nodes' => [
|
||||
[
|
||||
'host' => env('TYPESENSE_HOST', 'localhost'),
|
||||
'port' => env('TYPESENSE_PORT', '8108'),
|
||||
'path' => env('TYPESENSE_PATH', ''),
|
||||
'protocol' => env('TYPESENSE_PROTOCOL', 'http'),
|
||||
],
|
||||
],
|
||||
'nearest_node' => [
|
||||
'host' => env('TYPESENSE_HOST', 'localhost'),
|
||||
'port' => env('TYPESENSE_PORT', '8108'),
|
||||
'path' => env('TYPESENSE_PATH', ''),
|
||||
'protocol' => env('TYPESENSE_PROTOCOL', 'http'),
|
||||
],
|
||||
'connection_timeout_seconds' => env('TYPESENSE_CONNECTION_TIMEOUT_SECONDS', 2),
|
||||
'healthcheck_interval_seconds' => env('TYPESENSE_HEALTHCHECK_INTERVAL_SECONDS', 30),
|
||||
'num_retries' => env('TYPESENSE_NUM_RETRIES', 3),
|
||||
'retry_interval_seconds' => env('TYPESENSE_RETRY_INTERVAL_SECONDS', 1),
|
||||
],
|
||||
// 'max_total_results' => env('TYPESENSE_MAX_TOTAL_RESULTS', 1000),
|
||||
'model-settings' => [
|
||||
// User::class => [
|
||||
// 'collection-schema' => [
|
||||
// 'fields' => [
|
||||
// [
|
||||
// 'name' => 'id',
|
||||
// 'type' => 'string',
|
||||
// ],
|
||||
// [
|
||||
// 'name' => 'name',
|
||||
// 'type' => 'string',
|
||||
// ],
|
||||
// [
|
||||
// 'name' => 'created_at',
|
||||
// 'type' => 'int64',
|
||||
// ],
|
||||
// ],
|
||||
// 'default_sorting_field' => 'created_at',
|
||||
// ],
|
||||
// 'search-parameters' => [
|
||||
// 'query_by' => 'name'
|
||||
// ],
|
||||
// ],
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Third Party Services
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This file is for storing the credentials for third party services such
|
||||
| as Mailgun, Postmark, AWS and more. This file provides the de facto
|
||||
| location for this type of information, allowing packages to have
|
||||
| a conventional file to locate the various service credentials.
|
||||
|
|
||||
*/
|
||||
|
||||
'postmark' => [
|
||||
'token' => env('POSTMARK_TOKEN'),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
],
|
||||
|
||||
'resend' => [
|
||||
'key' => env('RESEND_KEY'),
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'notifications' => [
|
||||
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
|
||||
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,217 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Session Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines the default session driver that is utilized for
|
||||
| incoming requests. Laravel supports a variety of storage options to
|
||||
| persist session data. Database storage is a great default choice.
|
||||
|
|
||||
| Supported: "file", "cookie", "database", "memcached",
|
||||
| "redis", "dynamodb", "array"
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => env('SESSION_DRIVER', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Lifetime
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the number of minutes that you wish the session
|
||||
| to be allowed to remain idle before it expires. If you want them
|
||||
| to expire immediately when the browser is closed then you may
|
||||
| indicate that via the expire_on_close configuration option.
|
||||
|
|
||||
*/
|
||||
|
||||
'lifetime' => (int) env('SESSION_LIFETIME', 120),
|
||||
|
||||
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Encryption
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to easily specify that all of your session data
|
||||
| should be encrypted before it's stored. All encryption is performed
|
||||
| automatically by Laravel and you may use the session like normal.
|
||||
|
|
||||
*/
|
||||
|
||||
'encrypt' => env('SESSION_ENCRYPT', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session File Location
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the "file" session driver, the session files are placed
|
||||
| on disk. The default storage location is defined here; however, you
|
||||
| are free to provide another location where they should be stored.
|
||||
|
|
||||
*/
|
||||
|
||||
'files' => storage_path('framework/sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Connection
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" or "redis" session drivers, you may specify a
|
||||
| connection that should be used to manage these sessions. This should
|
||||
| correspond to a connection in your database configuration options.
|
||||
|
|
||||
*/
|
||||
|
||||
'connection' => env('SESSION_CONNECTION'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" session driver, you may specify the table to
|
||||
| be used to store sessions. Of course, a sensible default is defined
|
||||
| for you; however, you're welcome to change this to another table.
|
||||
|
|
||||
*/
|
||||
|
||||
'table' => env('SESSION_TABLE', 'sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using one of the framework's cache driven session backends, you may
|
||||
| define the cache store which should be used to store the session data
|
||||
| between requests. This must match one of your defined cache stores.
|
||||
|
|
||||
| Affects: "apc", "dynamodb", "memcached", "redis"
|
||||
|
|
||||
*/
|
||||
|
||||
'store' => env('SESSION_STORE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Sweeping Lottery
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Some session drivers must manually sweep their storage location to get
|
||||
| rid of old sessions from storage. Here are the chances that it will
|
||||
| happen on a given request. By default, the odds are 2 out of 100.
|
||||
|
|
||||
*/
|
||||
|
||||
'lottery' => [2, 100],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may change the name of the session cookie that is created by
|
||||
| the framework. Typically, you should not need to change this value
|
||||
| since doing so does not grant a meaningful security improvement.
|
||||
|
|
||||
*/
|
||||
|
||||
'cookie' => env(
|
||||
'SESSION_COOKIE',
|
||||
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The session cookie path determines the path for which the cookie will
|
||||
| be regarded as available. Typically, this will be the root path of
|
||||
| your application, but you're free to change this when necessary.
|
||||
|
|
||||
*/
|
||||
|
||||
'path' => env('SESSION_PATH', '/'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Domain
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the domain and subdomains the session cookie is
|
||||
| available to. By default, the cookie will be available to the root
|
||||
| domain and all subdomains. Typically, this shouldn't be changed.
|
||||
|
|
||||
*/
|
||||
|
||||
'domain' => env('SESSION_DOMAIN'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTPS Only Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By setting this option to true, session cookies will only be sent back
|
||||
| to the server if the browser has a HTTPS connection. This will keep
|
||||
| the cookie from being sent to you when it can't be done securely.
|
||||
|
|
||||
*/
|
||||
|
||||
'secure' => env('SESSION_SECURE_COOKIE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTP Access Only
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will prevent JavaScript from accessing the
|
||||
| value of the cookie and the cookie will only be accessible through
|
||||
| the HTTP protocol. It's unlikely you should disable this option.
|
||||
|
|
||||
*/
|
||||
|
||||
'http_only' => env('SESSION_HTTP_ONLY', true),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Same-Site Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines how your cookies behave when cross-site requests
|
||||
| take place, and can be used to mitigate CSRF attacks. By default, we
|
||||
| will set this value to "lax" to permit secure cross-site requests.
|
||||
|
|
||||
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
||||
|
|
||||
| Supported: "lax", "strict", "none", null
|
||||
|
|
||||
*/
|
||||
|
||||
'same_site' => env('SESSION_SAME_SITE', 'lax'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Partitioned Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will tie the cookie to the top-level site for
|
||||
| a cross-site context. Partitioned cookies are accepted by the browser
|
||||
| when flagged "secure" and the Same-Site attribute is set to "none".
|
||||
|
|
||||
*/
|
||||
|
||||
'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1 @@
|
|||
*.sqlite*
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Person>
|
||||
*/
|
||||
class PersonFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'surname' => $this->faker->lastName,
|
||||
'christian_name' => $this->faker->firstName,
|
||||
'full_name' => function (array $attributes) {
|
||||
return $attributes['christian_name'] . ' ' . $attributes['surname'];
|
||||
},
|
||||
'date_of_birth' => $this->faker->date('Y-m-d', '-30 years'),
|
||||
'place_of_birth' => $this->faker->city,
|
||||
'date_of_death' => $this->faker->optional(0.3)->date('Y-m-d'),
|
||||
'occupation' => $this->faker->jobTitle,
|
||||
'additional_notes' => $this->faker->optional()->paragraph,
|
||||
'reference' => $this->faker->optional()->bothify('REF-####-???'),
|
||||
'id_card_no' => $this->faker->optional()->bothify('ID-######')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->integer('expiration');
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->integer('expiration');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('person', function (Blueprint $table) {
|
||||
$table->id('person_id');
|
||||
$table->string('surname', 100)->nullable();
|
||||
$table->string('christian_name', 100)->nullable();
|
||||
$table->string('full_name', 200)->nullable();
|
||||
$table->date('date_of_birth')->nullable();
|
||||
$table->string('place_of_birth', 100)->nullable();
|
||||
$table->date('date_of_death')->nullable();
|
||||
$table->string('occupation', 100)->nullable();
|
||||
$table->text('additional_notes')->nullable();
|
||||
$table->string('reference', 100)->nullable();
|
||||
$table->string('id_card_no', 50)->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('person');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('migration', function (Blueprint $table) {
|
||||
$table->id('migration_id');
|
||||
$table->foreignId('person_id')->constrained('person', 'person_id')->cascadeOnDelete();
|
||||
$table->date('date_of_arrival_aus')->nullable();
|
||||
$table->date('date_of_arrival_nt')->nullable();
|
||||
$table->string('arrival_period', 50)->nullable();
|
||||
$table->string('data_source', 100)->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('migration');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('naturalization', function (Blueprint $table) {
|
||||
$table->id('naturalization_id');
|
||||
$table->foreignId('person_id')->constrained('person', 'person_id')->cascadeOnDelete();
|
||||
$table->date('date_of_naturalisation')->nullable();
|
||||
$table->string('no_of_cert', 50)->nullable();
|
||||
$table->string('issued_at', 100)->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('naturalization');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('residence', function (Blueprint $table) {
|
||||
$table->id('residence_id');
|
||||
$table->foreignId('person_id')->constrained('person', 'person_id')->cascadeOnDelete();
|
||||
$table->boolean('darwin')->default(false);
|
||||
$table->boolean('katherine')->default(false);
|
||||
$table->boolean('tennant_creek')->default(false);
|
||||
$table->boolean('alice_springs')->default(false);
|
||||
$table->string('home_at_death', 100)->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('residence');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('family', function (Blueprint $table) {
|
||||
$table->id('family_id');
|
||||
$table->foreignId('person_id')->constrained('person', 'person_id')->cascadeOnDelete();
|
||||
$table->text('names_of_parents')->nullable();
|
||||
$table->text('names_of_children')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('family');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('internment', function (Blueprint $table) {
|
||||
$table->id('internment_id');
|
||||
$table->foreignId('person_id')->constrained('person', 'person_id')->cascadeOnDelete();
|
||||
$table->string('corps_issued', 100)->nullable();
|
||||
$table->string('interned_in', 100)->nullable();
|
||||
$table->string('sent_to', 100)->nullable();
|
||||
$table->string('internee_occupation', 100)->nullable();
|
||||
$table->text('internee_address')->nullable();
|
||||
$table->string('cav', 50)->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('internment');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('personal_access_tokens', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('tokenable');
|
||||
$table->string('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('personal_access_tokens');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->boolean('is_admin')->default(false)->after('password');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('is_admin');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('residence', function (Blueprint $table) {
|
||||
// Add the new town_or_city column
|
||||
$table->string('town_or_city', 100)->nullable()->after('person_id');
|
||||
|
||||
// Remove the boolean location columns
|
||||
$table->dropColumn([
|
||||
'darwin',
|
||||
'katherine',
|
||||
'tennant_creek',
|
||||
'alice_springs'
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('residence', function (Blueprint $table) {
|
||||
// Add back the boolean location columns
|
||||
$table->boolean('darwin')->default(false)->after('person_id');
|
||||
$table->boolean('katherine')->default(false)->after('darwin');
|
||||
$table->boolean('tennant_creek')->default(false)->after('katherine');
|
||||
$table->boolean('alice_springs')->default(false)->after('tennant_creek');
|
||||
|
||||
// Remove the town_or_city column
|
||||
$table->dropColumn('town_or_city');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('activity_logs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->nullable()->constrained()->onDelete('set null');
|
||||
$table->string('action'); // e.g., create, update, delete, duplicate
|
||||
$table->string('model_type'); // e.g., App\Models\Person
|
||||
$table->unsignedBigInteger('model_id');
|
||||
$table->json('changes')->nullable(); // Stores old and new values
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('activity_logs');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateActivityLogTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->create(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('log_name')->nullable();
|
||||
$table->text('description');
|
||||
$table->nullableMorphs('subject', 'subject');
|
||||
$table->nullableMorphs('causer', 'causer');
|
||||
$table->string('causer_name')->nullable(); // 👈 New column
|
||||
$table->json('properties')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index('log_name');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->dropIfExists(config('activitylog.table_name'));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddEventColumnToActivityLogTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->string('event')->nullable()->after('subject_type');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->dropColumn('event');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddBatchUuidColumnToActivityLogTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->uuid('batch_uuid')->nullable()->after('properties');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->dropColumn('batch_uuid');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('photos', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('person_id');
|
||||
$table->string('filename');
|
||||
$table->string('original_filename')->nullable();
|
||||
$table->string('file_path');
|
||||
$table->string('mime_type')->nullable();
|
||||
$table->integer('file_size')->nullable(); // in KB
|
||||
$table->boolean('is_profile_photo')->default(false);
|
||||
$table->text('caption')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
// Foreign key constraint
|
||||
$table->foreign('person_id')
|
||||
->references('person_id')
|
||||
->on('person')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('photos');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class AdminUserSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
User::create([
|
||||
'name' => 'Admin User',
|
||||
'email' => 'admin@example.com',
|
||||
'password' => Hash::make('Admin123!'),
|
||||
'is_admin' => true,
|
||||
]);
|
||||
|
||||
$this->command->info('Admin user created successfully with email: admin@example.com and password: Admin123!');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// Create admin user for testing the authentication system
|
||||
$this->call([
|
||||
AdminUserSeeder::class,
|
||||
PersonSeeder::class, // Seed 100 sample Person records
|
||||
PhotoSeeder::class, // Seed photos for the Person records
|
||||
]);
|
||||
|
||||
// Create a regular user for testing
|
||||
User::factory()->create([
|
||||
'name' => 'Regular User',
|
||||
'email' => 'user@example.com',
|
||||
'is_admin' => false,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Person;
|
||||
use App\Models\Migration;
|
||||
use App\Models\Residence;
|
||||
use App\Models\Family;
|
||||
use App\Models\Naturalization;
|
||||
use App\Models\Internment;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Faker\Factory as Faker;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class PersonSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$faker = Faker::create();
|
||||
|
||||
$this->command->info('Creating 100 sample Person records with related data...');
|
||||
|
||||
// Create 100 sample Person records
|
||||
for ($i = 0; $i < 100; $i++) {
|
||||
$surname = $faker->lastName;
|
||||
$christianName = $faker->firstName;
|
||||
|
||||
// Randomly decide if person is deceased
|
||||
$isDeceased = $faker->boolean(30); // 30% chance of being deceased
|
||||
|
||||
// Generate dates (past dates for birth, future or null for death)
|
||||
$dob = $faker->dateTimeBetween('-100 years', '-20 years');
|
||||
$dod = $isDeceased ? $faker->dateTimeBetween($dob, 'now') : null;
|
||||
|
||||
// Create the person record
|
||||
$person = Person::create([
|
||||
'surname' => $surname,
|
||||
'christian_name' => $christianName,
|
||||
'full_name' => $christianName . ' ' . $surname,
|
||||
'date_of_birth' => $dob,
|
||||
'place_of_birth' => $faker->city . ', ' . $faker->country,
|
||||
'date_of_death' => $dod,
|
||||
'occupation' => $faker->jobTitle,
|
||||
'additional_notes' => $faker->boolean(70) ? $faker->paragraph(2) : null,
|
||||
'reference' => $faker->boolean(50) ? 'REF-' . $faker->randomNumber(5) : null,
|
||||
'id_card_no' => 'ID-' . $faker->unique()->randomNumber(8),
|
||||
]);
|
||||
|
||||
// Create Migration data (80% chance)
|
||||
if ($faker->boolean(80)) {
|
||||
$arrivalAus = $faker->dateTimeBetween($dob, '-1 years');
|
||||
$arrivalNT = $faker->dateTimeBetween($arrivalAus, '+2 years');
|
||||
|
||||
Migration::create([
|
||||
'person_id' => $person->person_id,
|
||||
'date_of_arrival_aus' => $arrivalAus,
|
||||
'date_of_arrival_nt' => $arrivalNT,
|
||||
'arrival_period' => $faker->randomElement(['Pre-WWII', 'Post-WWII', 'Modern Era']),
|
||||
'data_source' => $faker->randomElement(['Archives', 'Family Records', 'Historical Documents', 'Interviews']),
|
||||
]);
|
||||
}
|
||||
|
||||
// Create Residence data (70% chance)
|
||||
if ($faker->boolean(70)) {
|
||||
// Use only specific Northern Territory locations
|
||||
$ntLocations = ['Darwin', 'Tennant Creek', 'Katherine', 'Alice Springs'];
|
||||
|
||||
Residence::create([
|
||||
'person_id' => $person->person_id,
|
||||
'town_or_city' => $faker->randomElement($ntLocations),
|
||||
'home_at_death' => $isDeceased ? $faker->streetAddress . ', ' . $faker->randomElement($ntLocations) : null,
|
||||
]);
|
||||
}
|
||||
|
||||
// Create Family data (60% chance)
|
||||
if ($faker->boolean(60)) {
|
||||
Family::create([
|
||||
'person_id' => $person->person_id,
|
||||
'names_of_parents' => $faker->boolean(70) ? $faker->name . ' & ' . $faker->name : null,
|
||||
'names_of_children' => $faker->boolean(50) ? implode(', ', $faker->words($faker->numberBetween(1, 4))) : null,
|
||||
]);
|
||||
}
|
||||
|
||||
// Create Naturalization data (40% chance)
|
||||
if ($faker->boolean(40)) {
|
||||
$naturalizationDate = $faker->dateTimeBetween($dob, 'now');
|
||||
|
||||
Naturalization::create([
|
||||
'person_id' => $person->person_id,
|
||||
'date_of_naturalisation' => $naturalizationDate,
|
||||
'no_of_cert' => 'CERT-' . $faker->unique()->randomNumber(6),
|
||||
'issued_at' => $faker->city,
|
||||
]);
|
||||
}
|
||||
|
||||
// Create Internment data (10% chance - rare historical event)
|
||||
if ($faker->boolean(10)) {
|
||||
|
||||
Internment::create([
|
||||
'person_id' => $person->person_id,
|
||||
'corps_issued' => $faker->randomElement(['Army', 'Navy', 'Air Force']),
|
||||
'interned_in' => $faker->city,
|
||||
'sent_to' => $faker->boolean(80) ? $faker->city : null,
|
||||
'internee_occupation' => $faker->jobTitle,
|
||||
'internee_address' => $faker->address,
|
||||
'cav' => $faker->boolean(50) ? $faker->randomNumber(5) : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->command->info('100 sample Person records created successfully with related data');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Person;
|
||||
use App\Models\Photo;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class PhotoSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// Create the storage directory if it doesn't exist
|
||||
if (!File::exists(storage_path('app/public/photos'))) {
|
||||
File::makeDirectory(storage_path('app/public/photos'), 0755, true);
|
||||
}
|
||||
|
||||
// Sample image URLs for testing
|
||||
$sampleImages = [
|
||||
'https://randomuser.me/api/portraits/men/1.jpg',
|
||||
'https://randomuser.me/api/portraits/men/2.jpg',
|
||||
'https://randomuser.me/api/portraits/men/3.jpg',
|
||||
'https://randomuser.me/api/portraits/women/1.jpg',
|
||||
'https://randomuser.me/api/portraits/women/2.jpg',
|
||||
'https://randomuser.me/api/portraits/women/3.jpg',
|
||||
];
|
||||
|
||||
// Sample captions
|
||||
$sampleCaptions = [
|
||||
'Official ID photo',
|
||||
'Family portrait',
|
||||
'At work',
|
||||
'Travel document photo',
|
||||
'Residence permit photo',
|
||||
'Personal photo',
|
||||
];
|
||||
|
||||
// Get all person records
|
||||
$persons = Person::all();
|
||||
|
||||
// Process each person
|
||||
foreach ($persons as $person) {
|
||||
// Skip some persons to have variety (30% chance to skip)
|
||||
if (rand(1, 10) <= 3) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Create 1-3 photos for this person
|
||||
$numPhotos = rand(1, 3);
|
||||
$profilePhotoSet = false;
|
||||
|
||||
for ($i = 0; $i < $numPhotos; $i++) {
|
||||
// Choose a random sample image
|
||||
$imageUrl = $sampleImages[array_rand($sampleImages)];
|
||||
$imageData = file_get_contents($imageUrl);
|
||||
|
||||
// Create directory for this person if it doesn't exist
|
||||
$personDir = storage_path('app/public/photos/' . $person->person_id);
|
||||
if (!File::exists($personDir)) {
|
||||
File::makeDirectory($personDir, 0755, true);
|
||||
}
|
||||
|
||||
// Generate a unique filename
|
||||
$filename = Str::uuid() . '.jpg';
|
||||
$fullPath = $personDir . '/' . $filename;
|
||||
|
||||
// Save the image file
|
||||
file_put_contents($fullPath, $imageData);
|
||||
|
||||
// Choose if this should be a profile photo
|
||||
// First photo has 70% chance, otherwise 0% chance
|
||||
$isProfilePhoto = !$profilePhotoSet && (rand(1, 10) <= 7);
|
||||
|
||||
if ($isProfilePhoto) {
|
||||
$profilePhotoSet = true;
|
||||
}
|
||||
|
||||
// Create the photo record
|
||||
$photo = new Photo([
|
||||
'person_id' => $person->person_id,
|
||||
'filename' => $filename,
|
||||
'original_filename' => 'sample_' . rand(1000, 9999) . '.jpg',
|
||||
'file_path' => '/storage/photos/' . $person->person_id . '/' . $filename,
|
||||
'mime_type' => 'image/jpeg',
|
||||
'file_size' => strlen($imageData) / 1024, // Convert to KB
|
||||
'caption' => $sampleCaptions[array_rand($sampleCaptions)],
|
||||
'is_profile_photo' => $isProfilePhoto
|
||||
]);
|
||||
|
||||
$photo->save();
|
||||
}
|
||||
}
|
||||
|
||||
$this->command->info('Created photos for ' . Photo::count() . ' person records');
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"dev": "vite"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/vite": "^4.0.0",
|
||||
"axios": "^1.8.2",
|
||||
"concurrently": "^9.0.1",
|
||||
"laravel-vite-plugin": "^1.2.0",
|
||||
"tailwindcss": "^4.0.0",
|
||||
"vite": "^6.2.4"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Unit">
|
||||
<directory>tests/Unit</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Feature">
|
||||
<directory>tests/Feature</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<source>
|
||||
<include>
|
||||
<directory>app</directory>
|
||||
</include>
|
||||
</source>
|
||||
<php>
|
||||
<env name="APP_ENV" value="testing"/>
|
||||
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
|
||||
<env name="BCRYPT_ROUNDS" value="4"/>
|
||||
<env name="CACHE_STORE" value="array"/>
|
||||
<env name="DB_CONNECTION" value="sqlite"/>
|
||||
<env name="DB_DATABASE" value=":memory:"/>
|
||||
<env name="MAIL_MAILER" value="array"/>
|
||||
<env name="PULSE_ENABLED" value="false"/>
|
||||
<env name="QUEUE_CONNECTION" value="sync"/>
|
||||
<env name="SESSION_DRIVER" value="array"/>
|
||||
<env name="TELESCOPE_ENABLED" value="false"/>
|
||||
</php>
|
||||
</phpunit>
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<IfModule mod_rewrite.c>
|
||||
<IfModule mod_negotiation.c>
|
||||
Options -MultiViews -Indexes
|
||||
</IfModule>
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
# Handle Authorization Header
|
||||
RewriteCond %{HTTP:Authorization} .
|
||||
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||
|
||||
# Handle X-XSRF-Token Header
|
||||
RewriteCond %{HTTP:x-xsrf-token} .
|
||||
RewriteRule .* - [E=HTTP_X_XSRF_TOKEN:%{HTTP:X-XSRF-Token}]
|
||||
|
||||
# Redirect Trailing Slashes If Not A Folder...
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_URI} (.+)/$
|
||||
RewriteRule ^ %1 [L,R=301]
|
||||
|
||||
# Send Requests To Front Controller...
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [L]
|
||||
</IfModule>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
|
After Width: | Height: | Size: 1.8 MiB |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,14 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite + React + TS</title>
|
||||
<script type="module" crossorigin src="/assets/index-DhLmNHHP.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-DP8Dc-el.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.5 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 973 KiB |
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="1200" fill="none"><rect width="1200" height="1200" fill="#EAEAEA" rx="3"/><g opacity=".5"><g opacity=".5"><path fill="#FAFAFA" d="M600.709 736.5c-75.454 0-136.621-61.167-136.621-136.62 0-75.454 61.167-136.621 136.621-136.621 75.453 0 136.62 61.167 136.62 136.621 0 75.453-61.167 136.62-136.62 136.62Z"/><path stroke="#C9C9C9" stroke-width="2.418" d="M600.709 736.5c-75.454 0-136.621-61.167-136.621-136.62 0-75.454 61.167-136.621 136.621-136.621 75.453 0 136.62 61.167 136.62 136.621 0 75.453-61.167 136.62-136.62 136.62Z"/></g><path stroke="url(#a)" stroke-width="2.418" d="M0-1.209h553.581" transform="scale(1 -1) rotate(45 1163.11 91.165)"/><path stroke="url(#b)" stroke-width="2.418" d="M404.846 598.671h391.726"/><path stroke="url(#c)" stroke-width="2.418" d="M599.5 795.742V404.017"/><path stroke="url(#d)" stroke-width="2.418" d="m795.717 796.597-391.441-391.44"/><path fill="#fff" d="M600.709 656.704c-31.384 0-56.825-25.441-56.825-56.824 0-31.384 25.441-56.825 56.825-56.825 31.383 0 56.824 25.441 56.824 56.825 0 31.383-25.441 56.824-56.824 56.824Z"/><g clip-path="url(#e)"><path fill="#666" fill-rule="evenodd" d="M616.426 586.58h-31.434v16.176l3.553-3.554.531-.531h9.068l.074-.074 8.463-8.463h2.565l7.18 7.181V586.58Zm-15.715 14.654 3.698 3.699 1.283 1.282-2.565 2.565-1.282-1.283-5.2-5.199h-6.066l-5.514 5.514-.073.073v2.876a2.418 2.418 0 0 0 2.418 2.418h26.598a2.418 2.418 0 0 0 2.418-2.418v-8.317l-8.463-8.463-7.181 7.181-.071.072Zm-19.347 5.442v4.085a6.045 6.045 0 0 0 6.046 6.045h26.598a6.044 6.044 0 0 0 6.045-6.045v-7.108l1.356-1.355-1.282-1.283-.074-.073v-17.989h-38.689v23.43l-.146.146.146.147Z" clip-rule="evenodd"/></g><path stroke="#C9C9C9" stroke-width="2.418" d="M600.709 656.704c-31.384 0-56.825-25.441-56.825-56.824 0-31.384 25.441-56.825 56.825-56.825 31.383 0 56.824 25.441 56.824 56.825 0 31.383-25.441 56.824-56.824 56.824Z"/></g><defs><linearGradient id="a" x1="554.061" x2="-.48" y1=".083" y2=".087" gradientUnits="userSpaceOnUse"><stop stop-color="#C9C9C9" stop-opacity="0"/><stop offset=".208" stop-color="#C9C9C9"/><stop offset=".792" stop-color="#C9C9C9"/><stop offset="1" stop-color="#C9C9C9" stop-opacity="0"/></linearGradient><linearGradient id="b" x1="796.912" x2="404.507" y1="599.963" y2="599.965" gradientUnits="userSpaceOnUse"><stop stop-color="#C9C9C9" stop-opacity="0"/><stop offset=".208" stop-color="#C9C9C9"/><stop offset=".792" stop-color="#C9C9C9"/><stop offset="1" stop-color="#C9C9C9" stop-opacity="0"/></linearGradient><linearGradient id="c" x1="600.792" x2="600.794" y1="403.677" y2="796.082" gradientUnits="userSpaceOnUse"><stop stop-color="#C9C9C9" stop-opacity="0"/><stop offset=".208" stop-color="#C9C9C9"/><stop offset=".792" stop-color="#C9C9C9"/><stop offset="1" stop-color="#C9C9C9" stop-opacity="0"/></linearGradient><linearGradient id="d" x1="404.85" x2="796.972" y1="403.903" y2="796.02" gradientUnits="userSpaceOnUse"><stop stop-color="#C9C9C9" stop-opacity="0"/><stop offset=".208" stop-color="#C9C9C9"/><stop offset=".792" stop-color="#C9C9C9"/><stop offset="1" stop-color="#C9C9C9" stop-opacity="0"/></linearGradient><clipPath id="e"><path fill="#fff" d="M581.364 580.535h38.689v38.689h-38.689z"/></clipPath></defs></svg>
|
||||
|
After Width: | Height: | Size: 3.2 KiB |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue