2017 © Pedro Peláez
 

library api

Laravel REST API

image

koiiiey/api

Laravel REST API

  • Tuesday, May 22, 2018
  • by KoIIIeY
  • Repository
  • 3 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 400 % Grown

The README.md

API doc

Auth token header Authorization: Bearer {api_token}, (*1)

Auth api

Login

  • method post
  • url /api/v1/auth/login
  • params email, password
  • return {api_token: 'Your api token'}

Register

  • method post
  • url /api/v1/auth/register
  • params email, name, password, password_confirmation
  • return {api_token: 'Your api token'}

Social

  • method post
  • url /api/v1/auth/social/{social_provider_name}
  • params client_id, code
  • return {api_token: 'Your api token'}

Get current user

  • method get
  • url /api/v1/auth/current
  • params with
  • return {user json}

Entities api

Get entities paginator

  • method get
  • url /api/v1/{entity_class_basename}
  • params filter, with, scope, per_page, page
  • return {total: 1,per_page: 30,current_page: 1,last_page: 1,next_page_url: null,prev_page_url: null,from: 1,to: 1,data: []}

Create entity

  • method post
  • url /api/v1/{entity_class_basename}
  • params entity_attributes
  • return {created entity json}

==, (*2)

example: {a: 1, b: 2, c: {v: 5, n:6}} <-- here C is related in model, (*3)

Get one entity

  • method get
  • url /api/v1/{entity_class_basename}/{id}
  • params with
  • return {entity json}

Update entity

  • method put
  • url /api/v1/{entity_class_basename}/{id}
  • params entity_attributes
  • return {updated entity json}

Destroy entity

  • method delete
  • url /api/v1/{entity_class_basename}/{id}
  • return empty json object {}

Relations api

Get entity relation

  • method get
  • url /api/v1/{parent_class_basename}/{id}/{relation_name}
  • params filter, with, scope
  • return {relation json} object for has one relation and array for has many
  • method post
  • url /api/v1/{parent_class_basename}/{id}/{relation_name}
  • params entity_attributes
  • return {created entity json}
  • method get
  • url /api/v1/{parent_class_basename}/{id}/{relation_name}/{id}
  • params with
  • return {entity json}
  • method put
  • url /api/v1/{parent_class_basename}/{id}/{relation_name}/{id}
  • params entity_attributes
  • return {updated entity json}
  • method delete
  • url /api/v1/{parent_class_basename}/{id}/{relation_name}/{id}
  • return empty json object {}

============================, (*4)

Static methods call

Example: /api/v1/{entity_class_basename}/call/{method_name}/{params}, (*5)

** INSTALLATION **

  1. composer require koiiiey/api
  2. in config/app.php
    1. providers => [ Koiiiey\Api\ApiServiceProvider::class, ]
  3. Call php artisan vendor:publish --tag=guestFile it will copy Guest.php model to /app/ directory. \App\Guest is class that uses for not-authorized users.
  4. Configure your auth by [https://laravel.com/docs/5.6/authorization]

The Versions

22/05 2018

dev-master

9999999-dev

Laravel REST API

  Sources   Download

MIT