https://github.com/sahapranta/laravel-auth-and-places-api
Laravel REST API for Authentication and retrieving places within a 5km radius using Google Map API
https://github.com/sahapranta/laravel-auth-and-places-api
Last synced: about 2 months ago
JSON representation
Laravel REST API for Authentication and retrieving places within a 5km radius using Google Map API
- Host: GitHub
- URL: https://github.com/sahapranta/laravel-auth-and-places-api
- Owner: sahapranta
- Created: 2023-06-07T07:37:27.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-07T16:38:34.000Z (almost 2 years ago)
- Last Synced: 2025-02-07T16:43:04.963Z (3 months ago)
- Language: PHP
- Size: 83 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Spacenus GmbH Assignment

This assignment is to setup laravel REST API for Authentication and retrieving places within a 5km radius using Google Map API that takes Latitude and Longitude as url params.
## Installation
- Clone the repository
- Run `composer install`
- Copy .env.example to .env
- Run `php artisan migrate --seed`
- Run `php artisan serve`I cannot provide Google Map API key because I don't have the that, So, you need to add the api key to the .env file.
- Set GOOGLE_MAP_API_KEY to the `.env`
#### Use this credential if seeded using default seeder while migration
```json
{
"email": "[email protected]",
"password": "password"
}
```## Routes
| Method | Route | Controller |
| ------ | ---------- | --------------------------- |
| GET | api/places | Api\PlaceController |
| GET | api/user | Api\AuthController@user |
| POST | api/signup | Api\AuthController@register |
| POST | api/login | Api\AuthController@login |
| POST | api/logout | Api\AuthController@logout |For simplicity sqlite is used as database, if needed change it to mysql from .env
## Testing
- Run `php artisan test`
# API Documentation
### Get Places
Retrieves a list of places based on latitude and longitude coordinates.
#### Request
`GET /api/places?lat=51.5074&long=-0.1278&radius=5000`
#### Query Parameters
| Parameter | Type | Description |
| --------- | ------ | ------------------------------------------- |
| lat | number | Latitude coordinate of the location |
| long | number | Longitude coordinate of the location |
| radius | number | (Optional) Radius in meters (default: 5000) |### Response
- Status Code: `200 OK`
#### Example Response Body
```json
{
"results": ["Place 1", "Place 2", "Place 3"]
}
```
### Login
#### Request
`POST /api/login`
#### Request Body
`email, password`
### Response
- Status Code: `200 OK`
#### Example Response Body
```json
{
"token": "1|okamKQ4M8Nb9bTL2jC218HxTdbArip30k4SL5Xal"
}
```- Status Code: `401 Unauthorized` if the email or password is incorrect.
### Register
#### Request
`POST /api/signup`
#### Request Body
`name,email,password`
#### Example Response Body
```json
{
"token": "1|okamKQ4M8Nb9bTL2jC218HxTdbArip30k4SL5Xal"
}
```