Skip to content

Commit

Permalink
Update Laravel to 11
Browse files Browse the repository at this point in the history
  • Loading branch information
danon committed May 22, 2024
1 parent 2df73cd commit e7e02c3
Show file tree
Hide file tree
Showing 16 changed files with 618 additions and 412 deletions.
8 changes: 4 additions & 4 deletions app/Http/Middleware/ThrottleSubmission.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Exceptions\ThrottleRequestsException;
use Illuminate\Http\Request;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Routing\Route;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Routing\Middleware\ThrottleRequests;

class ThrottleSubmission extends ThrottleRequests
{
Expand All @@ -35,12 +35,12 @@ protected function handleRequest($request, Closure $next, array $limits)

if ($this->isAttemptsLimited($request, $response)) {
foreach ($limits as $limit) {
$this->limiter->hit($limit->key, $limit->decayMinutes * 60);
$this->limiter->hit($limit->key, $limit->decaySeconds * 60 * 60);

$response = $this->addHeaders(
$response,
$limit->maxAttempts,
$this->calculateRemainingAttempts($limit->key, $limit->maxAttempts)
$this->calculateRemainingAttempts($limit->key, $limit->maxAttempts),
);
}
}
Expand All @@ -67,7 +67,7 @@ protected function isAttemptsLimited(Request $request, Response $response): bool
private function isOptionalFilled(Route $route): bool
{
$routeValues = collect($route->parameters())
->map(fn ($parameter) => !($parameter instanceof Model && !$parameter->exists) && !empty($parameter))
->map(fn($parameter) => !($parameter instanceof Model && !$parameter->exists) && !empty($parameter))
->filter()
->keys()
->toArray();
Expand Down
24 changes: 13 additions & 11 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
namespace Coyote\Providers;

use Carbon\Carbon;
use Coyote\Laravel\SocialiteOAuth;
use Coyote\Domain\OAuth\OAuth;
use Coyote\Forum;
use Coyote\Laravel\SocialiteOAuth;
use Coyote\Models\Asset;
use Coyote\Services\Elasticsearch\Api as EsApi;
use Coyote\Services\FormBuilder\FormBuilder;
use Coyote\Services\FormBuilder\FormInterface;
use Coyote\Services\FormBuilder\ValidatesWhenSubmitted;
use Coyote\Services\Guest;
use Coyote\Services\Forum\Tracker;
use Coyote\Services\Guest;
use Coyote\Services\Invoice;
use Coyote\User;
use GuzzleHttp\Client;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Support\Collection;
use Illuminate\Support\ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Pagination\Paginator;
use Illuminate\Routing\Events\RouteMatched;
use Illuminate\Routing\Redirector;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;
use Illuminate\Pagination\Paginator;

class AppServiceProvider extends ServiceProvider
{
Expand All @@ -37,7 +37,7 @@ public function boot()
// force HTTPS according to cloudflare HTTP_X_FORWARDED_PROTO header
$this->app['request']->server->set(
'HTTPS',
$this->app['request']->server('HTTP_X_FORWARDED_PROTO') === 'https'
$this->app['request']->server('HTTP_X_FORWARDED_PROTO') === 'https',
);

$this->app['validator']->extend('username', 'Coyote\Http\Validators\UserValidator@validateName');
Expand Down Expand Up @@ -97,7 +97,9 @@ public function boot()
public function register()
{
$this->app->singleton(Guest::class, function ($app) {
return (new Guest($app['session.store']->get('guest_id')))->setDefaultSessionTime(Carbon::createFromTimestamp($app['session.store']->get('created_at')));
$guest = new Guest($app['session.store']->get('guest_id'));
$createdAt = $app['session.store']->get('created_at');
return $guest->setDefaultSessionTime(Carbon::createFromTimestamp($createdAt ?? ''));
});

$this->app->bind(EsApi::class, function ($app) {
Expand All @@ -124,7 +126,7 @@ public function register()
$this->app->resolving(Invoice\Pdf::class, function (Invoice\Pdf $pdf, $app) {
$pdf->setVendor($app['config']->get('vendor'));
});

$this->app->singleton(OAuth::class, SocialiteOAuth::class);
}

Expand Down Expand Up @@ -154,7 +156,7 @@ private function registerMacros()
}

return $this->filter(function (User $user) use ($others) {
return ! $others->contains('id', $user->id);
return !$others->contains('id', $user->id);
});
});

Expand Down Expand Up @@ -216,7 +218,7 @@ private function registerMacros()
/** @var \Coyote\Post|\Coyote\Pm|\Coyote\Microblog|\Coyote\Firm $parent */
$parent = $this->getParent();

$assets = collect($assets)->map(fn ($attributes) => Asset::find($attributes['id']))->keyBy('id');
$assets = collect($assets)->map(fn($attributes) => Asset::find($attributes['id']))->keyBy('id');

$ids = $assets->pluck('id')->toArray();
$current = $parent->assets->keyBy('id');
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
"florianv/laravel-swap": "^2.3.0",
"freelancehunt/php-credit-card-validator": "^3.2",
"fusonic/opengraph": "^2.0",
"hedii/laravel-gelf-logger": "^8.1.1",
"hedii/laravel-gelf-logger": "^9.0.0",
"incenteev/emoji-pattern": "^1.3",
"intervention/image": "^3.6.3",
"jenssegers/agent": "^2.3",
"laravel-notification-channels/webpush": "^7.1.0",
"laravel/framework": "^v10.43.0",
"laravel-notification-channels/webpush": "^8.0.0",
"laravel/framework": "^v11.7.0",
"laravel/helpers": "^1.2",
"laravel/legacy-factories": "^1.1",
"laravel/passport": "^v11.10.4",
"laravel/passport": "^v12.2.0",
"laravel/socialite": "^5.0",
"laravel/ui": "^v4.4.0",
"lavary/laravel-menu": "v1.8.3",
Expand All @@ -47,15 +47,15 @@
"predis/predis": "^1.0",
"rawr/t-regx": "^v0.17.0",
"rcrowe/twigbridge": "^0.14.3",
"rdx/laravelcollective-html": "^6.4",
"sentry/sentry-laravel": "4.2.0",
"rdx/laravelcollective-html": "^v6.4.1",
"sentry/sentry-laravel": "^4.5.1",
"stripe/stripe-php": "^7.66",
"symfony/http-client": "^6.2",
"symfony/mailgun-mailer": "^6.2"
},
"require-dev": {
"fakerphp/faker": "^1.15",
"laravel/dusk": "^v7.12.1",
"laravel/dusk": "^v8.2.0",
"mockery/mockery": "^1.4",
"phpunit/phpunit": "^10.5.20",
"rawr/phpunit-data-provider": "^3.3"
Expand Down
Loading

0 comments on commit e7e02c3

Please sign in to comment.