This is a test project to demonstrate the creation of a small application using the Laravel framework. The project consists of a blog with two main entities: users and posts.
To set up the project, follow these steps:
-
Clone the repository to a convenient folder:
git clone git@github.com:ArthurWebWare/Ultra-Test.git cd Ultra-Test -
Build the Docker containers:
docker-compose build
-
Start the Docker containers:
docker-compose up -d
-
Access the running container:
docker exec -it laravel-app-php-cli bash -
Inside the container, run the following commands to download all dependencies, run the migrations, and seed the database with test data:
composer install php artisan migrate php artisan db:seed
No additional configuration is needed.
To use the application, start the Docker containers and access the application at localhost:8081.
Here are the available API endpoints:
-
User Registration and Authentication:
POST /register- Register a new userPOST /login- Log in a user
-
Posts:
GET /posts- Get a paginated list of all postsGET /post/{id}- Get a specific post by IDGET /users/{user}/posts- Get a paginated list of posts for a specific user
-
Authenticated Routes:
POST /post- Create a new postPUT /post/{id}- Update a postDELETE /post/{id}- Delete a postPOST /logout- Log out a user
This project includes custom console commands for processing post statuses:
-
CheckPostStatus
- Command:
posts:check-status - Description: This command checks the posts and marks those older than two days as inactive. It also queues the IDs of old posts for processing.
- Command:
-
ProcessPostStatus
- Command:
posts:process-status - Description: This command processes the queued post IDs and updates their status to inactive.
- Command:
To run the console commands, use the following syntax within the Docker container:
php artisan posts:check-status
php artisan posts:process-status