Code Monkey home page Code Monkey logo

mini-aspire-lumen5's Introduction

MiniAspire project with Lumen 5.2 Framework

Documentation for the framework can be found on the Lumen website.

Purpose

  • Build a simple API that allows to handle user loans: users, loans, and repayments
    • The loan term calculates as default is year.
    • The payment will pay for loan by period is 12 months(1 year).
    • The interest rate can be dynamic: year, month, quarter.
    • The user can create many loans and make repayments by each period.

Contents

Installation

  1. Requirement:
    • PHP >= 7.0.1
    • Mysql >= 5.6
    • Postman >= 7.1
  2. Setup:
    • Git clone: [email protected]:kieugol/mini-aspire-lumen5.git
    • Run composer: composer install
    • Change db configuration at .env file
      DB_HOST=localhost
      DB_PORT=3306
      DB_DATABASE=test
      DB_USERNAME=root
      DB_PASSWORD=root
      
    • Run migration: php artisan migrate --force
    • Setup apache, nginx to use local to run source code can refer here: Lumen Installation

Usage

User

Create a User

  • Using post method: https://krol.diqit.io/api/v1/user
  • Sample params:
      {
          "name": "Rol Kieu",
          "email": "[email protected]",
          "birthday": "1990-09-22",
          "phone": "09174747775",
          "address": "HCM City"
      }
    • Sample output:
      {
          "code": 200,
          "message": "Created successfully.",
          "data": {
              "name": "Rol Kieu",
              "email": "[email protected]",
              "birthday": "1990-09-22",
              "phone": "09174747775",
              "address": "HCM City",
              "updated_at": "2020-03-10 03:37:13",
              "created_at": "2020-03-10 03:37:13",
              "id": 2
          }
      }

Get List User

loan

Create a Loan

  • Using post method: https://krol.diqit.io/api/v1/loan
  • Sample params:
        {
          "user": 1,
          "repayment_frequency": 2,
          "loan_term": 2,
          "interest_rate": 6,
          "amount": 10000
        }
    -  user: go to api [Get list user](#get-list-user)
    -  repayment_frequency: go to api [Get all repayment frequency](#get-all-user)
    
  • Sample output:
        {
            "code": 200,
            "message": "Created successfully.",
            "data": {
                "id": 1
            }
        }

Get list loan

 {
     "code": 200,
     "message": "",
     "data": {
         "page": 1,
         "length": 10,
         "total_record": 1,
         "total_page": 1,
         "rows": [
             {
                 "id": 1,
                 "user_id": 1,
                 "term": 2,
                 "start_date": "2020-03-09",
                 "end_date": "2022-03-09",
                 "repayment_frequency": "Quarter",
                 "Loan_status": "Paying",
                 "interest_rate": 6,
                 "amount": 10000,
                 "payment_amount": 12500,
                 "interest_amount": 2500,
                 "remarks": "",
                 "created_at": "2020-03-09 16:13:17",
                 "updated_at": "2020-03-09 16:14:36"
             }
         ]
     }
 }

Get list Loan By User

 {
     "code": 200,
     "message": "",
     "data": [
         {
             "id": 1,
             "user_id": 1,
             "term": 2,
             "start_date": "2020-03-09",
             "end_date": "2022-03-09",
             "repayment_frequency": "Quarter",
             "Loan_status": "Paying",
             "interest_rate": 6,
             "amount": 10000,
             "payment_amount": 12500,
             "interest_amount": 2500,
             "remarks": "",
             "created_at": "2020-03-09 16:13:17",
             "updated_at": "2020-03-09 16:14:36"
         }
     ]
 }

Add payment for loan

  • Using get method: https://krol.diqit.io/api/v1/loan-payment/repayment
  • Sample params:
    • user: the user id
    • loan: loan id belongs to user
    • payment_date: the period need to pay
    • amount: the money need to pay for 1 period
     {
       "user": 1,
       "loan": 1,
       "payment_date": "2020-3-01",
       "amount": 880
     }
  • Sample output:
 {
     "code": 200,
     "message": "Your payment updated successfully.",
     "data": ""
 }

Get list loan payment by loan

 {
   "code": 200,
   "message": "",
   "data": [
     {
       "id": 2,
       "loan_id": 1,
       "due_date": "2020-04-30",
       "amount": 608.34,
       "principal_amount": 416.67,
       "interest_amount": 191.67,
       "balance": 9166.66,
       "remarks": "",
       "is_active": 0,
       "created_by": 0,
       "updated_by": 0,
       "created_at": "2020-03-09 16:13:17",
       "updated_at": "2020-03-09 16:13:17"
     }
   ]
 }

mini-aspire-lumen5's People

Contributors

kieugol avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.