laravel 8

This commit is contained in:
Denis Duliçi
2020-10-14 17:07:59 +03:00
parent b4e044b199
commit 1ba8835a2d
134 changed files with 3515 additions and 1952 deletions

View File

@@ -2,28 +2,12 @@
namespace App\Providers;
use Blade;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider as Provider;
use Schema;
class App extends Provider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
// Laravel db fix
Schema::defaultStringLength(191);
// @todo Remove the if control after 1.3 update
if (method_exists('Blade', 'withoutDoubleEncoding')) {
Blade::withoutDoubleEncoding();
}
}
/**
* Register any application services.
*
@@ -39,4 +23,17 @@ class App extends Provider
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
}
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
// Laravel db fix
Schema::defaultStringLength(191);
Paginator::useBootstrap();
}
}

View File

@@ -2,6 +2,8 @@
namespace App\Providers;
use Illuminate\Contracts\Auth\Access\Authorizable;
use Illuminate\Contracts\Auth\Access\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as Provider;
class Auth extends Provider
@@ -12,7 +14,7 @@ class Auth extends Provider
* @var array
*/
protected $policies = [
//'App\Model' => 'App\Policies\ModelPolicy',
//'App\Models\Model' => 'App\Policies\ModelPolicy',
];
/**
@@ -24,6 +26,11 @@ class Auth extends Provider
{
$this->registerPolicies();
//
// Register permissions to Laravel Gate
app(Gate::class)->before(function (Authorizable $user, string $ability) {
if (method_exists($user, 'hasPermission')) {
return $user->hasPermission($ability) ?: null;
}
});
}
}

View File

@@ -25,6 +25,7 @@ class Event extends Provider
'App\Listeners\Update\V20\Version2020',
'App\Listeners\Update\V20\Version2023',
'App\Listeners\Update\V20\Version2024',
'App\Listeners\Update\V21\Version210',
],
'Illuminate\Auth\Events\Login' => [
'App\Listeners\Auth\Login',

View File

@@ -2,11 +2,23 @@
namespace App\Providers;
use Illuminate\Support\Facades\Route as Facade;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as Provider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route as Facade;
class Route extends Provider
{
/**
* The path to the "home" route for your application.
*
* This is used by Laravel authentication to redirect users after login.
*
* @var string
*/
public const HOME = '/';
/**
* This namespace is applied to your controller routes.
*
@@ -64,6 +76,8 @@ class Route extends Provider
*/
protected function mapApiRoutes()
{
$this->configureRateLimiting();
Facade::prefix('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
@@ -155,4 +169,16 @@ class Route extends Provider
->namespace($this->namespace)
->group(base_path('routes/signed.php'));
}
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60);
});
}
}