Before getting started, make sure you have the following requirements installed on your system:
- PHP 8
- Laravel 8
- MongoDB 4.2
Follow these steps to get the project up and running on your local machine:
- Clone the repository to your local machine:
git clone https://github.com/bimprakosoo/test-inosoft.git
- Navigate to the project directory:
cd your-repository
- Install the project dependencies using Composer:
composer install
- Install MongoDB on your system. Refer to the official MongoDB documentation for installation instructions specific to your operating system: MongoDB Installation
- Set up your database configuration by creating a
.env
file. You can use the.env.example
file as a template:
cp .env.example .env
Update the following lines in the .env
file with your MongoDB connection details:
DB_CONNECTION=mongodb
DB_HOST=127.0.0.1
DB_PORT=27017
DB_DATABASE=your_database_name
DB_USERNAME=your_username
DB_PASSWORD=your_password
- Generate an application key:
php artisan key:generate
-
- Install the
tymon/jwt-auth
- Install the
composer require tymon/jwt-auth
- Generate the JWT secret key:
php artisan jwt:secret
- Run the database migrations to create the necessary tables:
php artisan migrate
- (Optional) Run the database seeder to populate the database with dummy data:
php artisan db:seed
- Run the unit tests to ensure everything is set up correctly:
php artisan test
- Start the development server:
php artisan serve
The application will be available at http://127.0.0.1:8000.
Provide instructions and examples for users to understand and use your project. Include examples of API endpoints, how to make requests, and expected responses.
Before testing the API endpoints, you need to register and login to obtain an access token. Follow these steps:
- Register a new user:
- Login with the registered user:
- Check Stock: Send a
POST
request tohttp://127.0.0.1:8000/api/kendaraan/check-stock
to check the stock of a vehicle. - Create Kendaraan Transaction: Send a
POST
request tohttp://127.0.0.1:8000/api/kendaraan-transactions
to create a new Kendaraan Transaction. - Get Sales Report: Send a
GET
request tohttp://127.0.0.1:8000/api/sales-report
to retrieve the sales report.
Send a POST
request to http://127.0.0.1:8000/api/register
with the following parameters:
{
"name": "Your Name",
"email": "[email protected]",
"password": "your-password"
}
Send a POST
request to http://127.0.0.1:8000/api/login
with the following parameters:
{
"email": "[email protected]",
"password": "your-password"
}
The response will include an access token that you can use to authenticate subsequent requests.
Once you have obtained the access token, you can test the API endpoints using a tool like Postman. Set the "Authorization" header in your requests with the access token in the following format:
Authorization: Bearer <access_token>
Here are some example API endpoints you can test:
Make sure to include the required parameters and provide the necessary authentication headers for each request.