Posted on: February 07, 2021 08:29 PM
Posted by: Renato
Views: 841
# Laravel 8
- 07/02/2021
## Rotas mudaram para um novo padrão
```php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PassportController;
Route::middleware('cors')->post('login', [PassportController::class, 'login']);
```
> Ou se voce quiser usar o padrao antigo, voce poderá usar tambem, mas para isto tem que adicionar no service provider (RouteServiceProvider), adicionando.
`protected $namespace = 'App\\Http\\Controllers';`
## Criar um script de sql dentro de database\schemaphp artisan schema:dump
## factories
Route::get('/factories', function(){
$user = \App\Models\User::factory()->count(4)->create();
// return $user;
return \App\Moddels\User::all();
});
## [Laravel 8 - Novidades] Rate Limiting Melhorias #laravel #php
- https://laravel.com/api/8.x/Illuminate/Cache/RateLimiting/Limit.html
```php
// Allow up to 60 requests in 1 minute for that route (= 1 req/s)
Route::get('api/v1/user', 'Api\UserController@index')->middleware('throttle:60,1');
// Allow up to 60 requests in 60 minutes for that route (= 1 req/m)
Route::post('api/v1/user', 'Api\UserController@store')->middleware('throttle:60,60');
// Rate Limiting for a whole group of routes
Route::group(['middleware' => 'throttle:60,1'], function () {
// [...]
});
```
```php
Route::middleware('throttle:3,1')->group(function () {
Route::get('/about', function () {
return "About Info";
});
});
```
Fontes:
- https://www.youtube.com/watch?v=ulWQZ8QWmas
- https://laravel.com/docs/8.x/releases
Donate to Site
Renato
Developer