Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- Simple, fast routing engine.
- Powerful dependency injection container.
- Multiple back-ends for session and cache storage.
- Expressive, intuitive database ORM.
- Database agnostic schema migrations.
- Robust background job processing.
- Real-time event broadcasting.
Laravel is accessible, powerful, and provides tools required for large, robust applications.
php composer install
- Verifique seu arquivo .env com as configurações corretas com o seu banco de dados
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
php artisan migrate --seed
php artisan serve
Post::with('user')->get()
Product::with('user')->get()
User::with('posts','products')->find(1)
Product::whereBetween('price', [100,500])->orderBy('price', 'desc')->get()
POST api/register
curl -XPOST http://127.0.0.1:8000/api/register -H "Content-Type: application/json" -d "{\"name\":\"Pedro Moreira\", \"email\": \"[email protected]\", \"password\": \"admin123123\", \"password_confirmation\": \"admin123123\"}"
POST api/login
curl -XPOST http://127.0.0.1:8000/api/login -H "Content-Type: application/json" -d "{\"email\": \"[email protected]\", \"password\": \"admin123123\"}"
OBS: Returned a token.
GET api/posts
GET api/posts/{id}
curl -XGET http://127.0.0.1:8000/api/posts/1
POST api/posts
curl -XPOST http://127.0.0.1:8000/api/posts -H "Content-Type: application/json" -H "Authorization: Bearer <login_token>" -d "{\"title\": \"Example Title\", \"content\": \"Example body of post.\"}"
PUT/PATCH api/posts/{id}
curl -XPUT http://127.0.0.1:8000/api/posts/1 -H "Content-Type: application/json" -H "Authorization: Bearer <login_token>" -d "{\"title\": \"Example title updated\", \"content\": \"Example body of post updated\"}"
DELETE api/posts/{id}
curl -XDELETE http://127.0.0.1:8000/api/posts/1 -H "Authorization: Bearer <login_token>"
GET api/users
curl -XGET http://127.0.0.1:8000/api/users -H "Authorization: Bearer <login_token>"
PUT/PATCH api/users/{id}
curl -XPUT http://127.0.0.1:8000/api/users/1 -H "Content-Type: application/json" -H "Authorization: Bearer <login_token>" -d "{\"name\": \"Joao Pedro Moreira\", \"email\": \"[email protected]\", \"password\": \"adminadmin\", \"password_confirmation\": \"adminadmin\"}"
DELETE api/users/{id}
curl -XDELETE http://127.0.0.1:8000/api/users/1 -H "Authorization: Bearer <login_token>"
GET api/products
curl -XGET http://127.0.0.1:8000/api/products -H "Authorization: Bearer <login_token>"
GET api/products
curl -XGET http://127.0.0.1:8000/api/products?per_page=1 -H "Authorization: Bearer <login_token>"
GET api/products
curl -XGET http://127.0.0.1:8000/api/products/{product} -H "Authorization: Bearer <login_token>"
PUT/PATCH api/products/{product}
curl -XPUT http://127.0.0.1:8000/api/products/{product} -H "Content-Type: application/json" -H "Authorization: Bearer <login_token>" -d "{\"name\": \"Example name Prod\", \"description\": \"Example description Prod\", \"price\": 1234.90}"
DELETE api/products/{product}
curl -XDELETE http://127.0.0.1:8000/api/products/{product} -H "Authorization: Bearer <login_token>"