First in Spanish then in English
Contenido 📝
En el siguiente proyecto se ha llevado a cabo la creación del backend para el proyecto final del bootcamp Full Stack Developer en GeeksHubs Academy. El proyecto completo debía realizarse en una duración de dos semanas y, en esta parte, se desarrolló una API REST utilizando Laravel, la cual fue utilizada para alimentar las vistas del frontend.
El proyecto consiste en una página web diseñada para los amantes de las plantas de interior. Los usuarios podrán buscar información detallada sobre diversas especies y, además, tendrán la opción de añadir las plantas que poseen a su perfil, lo que les permitirá llevar un control preciso de su riego y cuidado.
Tecnologías utilizadas:
- Clona el repositorio
$git clone 'url-repository'
- Instala las dependencias
composer install
- Crea el archivo
.env
y configura la base de datos - Ejecuta las migraciones y seeders
php artisan migrate
php artisan db:seed
- Conectamos el servidor
php artisan serve
- Ejecuta este archivo en Postman para habilitar el acceso a los endpoints del proyecto:
Endpoints
-
AUTH
-
REGISTER
POST http://localhost:8000/api/register
body:
{ "name": "Andrea", "surname": "Suarez", "email": "andrea@andrea.com", "password": "Andrea1234", "city": "Valencia", "country": "Spain" }
-
LOGIN
POST http://localhost:8000/api/login
body:
{ "email": "andrea@andrea.com", "password": "Andrea1234" }
-
LOGOUT
POST http://localhost:8000/api/logout
-
-
USERS
-
GET PROFILE
GET localhost:8000/api/profile
-
UPDATE PROFILE
PUT localhost:8000/api/profile
body:
{ "name": "Andrea", "surname": "Suarez", "city": "Valencia", "country": "Spain" }
-
DELETE PROFILE (as user)
DELETE localhost:8000/api/profile
-
DELETE PROFILE AS ADMIN (admin)
DELETE localhost:8000/api/profile/:id
-
RESTORE PROFILE (admin)
POST localhost:8000/api/profile/:id
-
GET All USERS (admin)
GET localhost:8000/api/allusers
-
GET DELETED USERS (admin)
GET localhost:8000/api/allusers/deleted
-
-
PLANTS
-
GET ALL PLANTS
GET localhost:8000/api/plants
-
GET PLANTS BY ID
GET localhost:8000/api/plants/:id
-
GET PLANTS BY NAME
POST localhost:8000/api/plants/name
body:
{ "name": "aloe" }
-
GET PLANTS BY SUNLIGHT
POST localhost:8000/api/plants/sunlight
body:
{ "sunlight": "Full sun" }
-
GET PLANTS BY WATERING
POST localhost:8000/api/plants/watering
body:
{ "watering": "Part sun/Part shade" }
-
GET PLANTS BY FLOWERS
POST localhost:8000/api/plants/flowers
body:
{ "flowers": true }
-
GET PLANTS BY POISONOUS
POST localhost:8000/api/plants/poisonous
body:
{ "poisonous": false }
-
CREATE PLANT
POST localhost:8000/api/plants
body:
{ "common_name": "Example", "scientific_name": "Example", "sunlight": "Full Sun", "watering": "Average", "flowers": true, "poisonous_to_pets": false }
-
-
MY PLANTS
-
GET MY PLANTS BY USER
GET localhost:8000/api/myplants
-
GET MY PLANTS BY ID
GET localhost:8000/api/myplants/:id
-
GET MY PLANTS BY PLANT ID
GET localhost:8000/api/myplants/plant/:id
-
GET MY PLANTS WATER TODAY
GET localhost:8000/api/myplants/watertoday
-
GET MY PLANTS NOT WATER TODAY
GET localhost:8000/api/myplants/notwatertoday
-
CREATE MY PLANT
POST localhost:8000/api/myplants/:id
body:
{ "name": "Kitchen little plant", "days_between_water" : 10 }
-
UPDATE MY PLANT
POST localhost:8000/api/myplants/:id
body:
{ "name": "Kitchen big plant", "days_between_water" : 7 }
-
DELETE MY PLANT
DELETE localhost:8000/api/myplants/:id
-
-
WATERING DATES
-
GET WATERING DATE
GET localhost:8000/api/water/:id
-
CREATE WATERING DATE
POST localhost:8000/api/water
body:
{ "my_plant_id": 20, "watered_on": "2023-07-22" }
-
UPDATE WATERING DATE
POST localhost:8000/api/water
body:
{ "id": 1, "watered_on": "2023-08-10" }
-
DELETE WATERING DATE
DELETE localhost:8000/api/water/:id
-
Este proyecto se encuentra bajo licencia MIT.
La información de la tabla de plantas se ha obtenido de perenual.com/docs/api
The following project involved the creation of the backend for the final project of the Full Stack Developer bootcamp at GeeksHubs Academy. The whole project needed to be completed in a duration of two weeks and, in this part, a REST API was developed using Laravel, which was used to feed the frontend views.
The project consists of a website designed for indoor plant lovers. Users will be able to search for detailed information on various species and will also have the option to add the plants they own to their profile, allowing them to keep precise control of their watering and care.
Technologies used:
- Clone the repository
$git clone 'url-repository'
. - Install dependencies
$composer install
. - Create the
.env
file and set up the database. - Run the
php artisan migrate
php artisan db:seed
migrations and seeders. - Connect the
php artisan serve
server. - Run this file in Postman to enable access to the project endpoints:
Endpoints
-
AUTH
-
REGISTER
POST http://localhost:8000/api/register
body:
{ "name": "Andrea", "surname": "Suarez", "email": "andrea@andrea.com", "password": "Andrea1234", "city": "Valencia", "country": "Spain" }
-
LOGIN
POST http://localhost:8000/api/login
body:
{ "email": "andrea@andrea.com", "password": "Andrea1234" }
-
LOGOUT
POST http://localhost:8000/api/logout
-
-
USERS
-
GET PROFILE
GET localhost:8000/api/profile
-
UPDATE PROFILE
PUT localhost:8000/api/profile
body:
{ "name": "Andrea", "surname": "Suarez", "city": "Valencia", "country": "Spain" }
-
DELETE PROFILE (as user)
DELETE localhost:8000/api/profile
-
DELETE PROFILE AS ADMIN (admin)
DELETE localhost:8000/api/profile/:id
-
RESTORE PROFILE (admin)
POST localhost:8000/api/profile/:id
-
GET All USERS (admin)
GET localhost:8000/api/allusers
-
GET DELETED USERS (admin)
GET localhost:8000/api/allusers/deleted
-
-
PLANTS
-
GET ALL PLANTS
GET localhost:8000/api/plants
-
GET PLANTS BY ID
GET localhost:8000/api/plants/:id
-
GET PLANTS BY NAME
POST localhost:8000/api/plants/name
body:
{ "name": "aloe" }
-
GET PLANTS BY SUNLIGHT
POST localhost:8000/api/plants/sunlight
body:
{ "sunlight": "Full sun" }
-
GET PLANTS BY WATERING
POST localhost:8000/api/plants/watering
body:
{ "watering": "Part sun/Part shade" }
-
GET PLANTS BY FLOWERS
POST localhost:8000/api/plants/flowers
body:
{ "flowers": true }
-
GET PLANTS BY POISONOUS
POST localhost:8000/api/plants/poisonous
body:
{ "poisonous": false }
-
CREATE PLANT
POST localhost:8000/api/plants
body:
{ "common_name": "Example", "scientific_name": "Example", "sunlight": "Full Sun", "watering": "Average", "flowers": true, "poisonous_to_pets": false }
-
-
MY PLANTS
-
GET MY PLANTS BY USER
GET localhost:8000/api/myplants
-
GET MY PLANTS BY ID
GET localhost:8000/api/myplants/:id
-
GET MY PLANTS BY PLANT ID
GET localhost:8000/api/myplants/plant/:id
-
GET MY PLANTS WATER TODAY
GET localhost:8000/api/myplants/watertoday
-
GET MY PLANTS NOT WATER TODAY
GET localhost:8000/api/myplants/notwatertoday
-
CREATE MY PLANT
POST localhost:8000/api/myplants/:id
body:
{ "name": "Kitchen little plant", "days_between_water" : 10 }
-
UPDATE MY PLANT
POST localhost:8000/api/myplants/:id
body:
{ "name": "Kitchen big plant", "days_between_water" : 7 }
-
DELETE MY PLANT
DELETE localhost:8000/api/myplants/:id
-
-
WATERING DATES
-
GET WATERING DATE
GET localhost:8000/api/water/:id
-
CREATE WATERING DATE
POST localhost:8000/api/water
body:
{ "my_plant_id": 20, "watered_on": "2023-07-22" }
-
UPDATE WATERING DATE
POST localhost:8000/api/water
body:
{ "id": 1, "watered_on": "2023-08-10" }
-
DELETE WATERING DATE
DELETE localhost:8000/api/water/:id
-
This project is under MIT licence.
The information in the table plants has been obtained from perenual.com/docs/api