Skip to content

Commit 8446203

Browse files
committed
Upgrade to Laravel 8
1 parent 1b80ecd commit 8446203

File tree

100 files changed

+9086
-8777
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+9086
-8777
lines changed

.env.example

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ APP_NAME=BIIGLE
55
APP_ENV="local"
66
APP_KEY=
77
APP_DEBUG=true
8-
LOG_CHANNEL=errorlog
98
APP_URL="http://localhost"
109
APP_TIMEZONE="Europe/Berlin"
1110

11+
LOG_CHANNEL=errorlog
12+
LOG_DEPRECATIONS_CHANNEL=null
13+
LOG_LEVEL=debug
14+
1215
ADMIN_EMAIL="[email protected]"
1316

1417
DB_CONNECTION="pgsql"
@@ -23,11 +26,14 @@ DB_PASSWORD="secret"
2326

2427
# normally you don't have to edit these
2528
CACHE_DRIVER="redis"
29+
FILESYSTEM_DRIVER=local
2630
SESSION_DRIVER="redis"
2731
SESSION_LIFETIME=120
2832
SESSION_SECURE_COOKIE=false
2933
QUEUE_CONNECTION="redis"
3034

35+
MEMCACHED_HOST=127.0.0.1
36+
3137
REDIS_HOST="127.0.0.1"
3238
REDIS_PASSWORD=null
3339
REDIS_PORT=6379
@@ -46,6 +52,7 @@ AWS_ACCESS_KEY_ID=
4652
AWS_SECRET_ACCESS_KEY=
4753
AWS_DEFAULT_REGION=us-east-1
4854
AWS_BUCKET=
55+
AWS_USE_PATH_STYLE_ENDPOINT=false
4956

5057
PUSHER_APP_ID=
5158
PUSHER_APP_KEY=

.gitattributes

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
* text=auto
2-
*.css linguist-vendored
3-
*.scss linguist-vendored
4-
*.js linguist-vendored
2+
3+
*.blade.php diff=html
4+
*.css diff=css
5+
*.html diff=html
6+
*.md diff=markdown
7+
*.php diff=php
8+
9+
/.github export-ignore
510
CHANGELOG.md export-ignore

.gitignore

+16-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1+
/node_modules
2+
/public/hot
3+
/public/storage
4+
/public/vendor
5+
/storage/*.key
6+
/storage/largo_patches
17
/vendor
2-
public/vendor
3-
node_modules
4-
public/hot
5-
tmp
6-
storage/largo_patches
7-
8-
npm-debug.log
98
.env
109
.env.backup
1110
.phpunit.result.cache
12-
*.sublime-*
13-
*.phar
14-
*.php_cs.cache
11+
docker-compose.override.yml
12+
Homestead.json
13+
Homestead.yaml
14+
npm-debug.log
15+
yarn-error.log
16+
/*.sublime-*
17+
/*.phar
18+
/*.php_cs.cache
19+
/.idea
20+
/.vscode

app/Annotation.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Biigle\Contracts\Annotation as AnnotationContract;
66
use Biigle\Traits\HasPointsAttribute;
77
use DB;
8+
use Illuminate\Database\Eloquent\Factories\HasFactory;
89
use Illuminate\Database\Eloquent\Model;
910

1011
/**
@@ -13,7 +14,7 @@
1314
*/
1415
abstract class Annotation extends Model implements AnnotationContract
1516
{
16-
use HasPointsAttribute;
17+
use HasPointsAttribute, HasFactory;
1718

1819
/**
1920
* The attributes excluded from the model's JSON form.

app/AnnotationLabel.php

+3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
namespace Biigle;
44

5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
56
use Illuminate\Database\Eloquent\Model;
67

78
abstract class AnnotationLabel extends Model
89
{
10+
use HasFactory;
11+
912
/**
1013
* The attributes that are mass assignable.
1114
*

app/AnnotationSession.php

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Carbon\Carbon;
66
use DB;
7+
use Illuminate\Database\Eloquent\Factories\HasFactory;
78
use Illuminate\Database\Eloquent\Model;
89

910
/**
@@ -12,6 +13,8 @@
1213
*/
1314
class AnnotationSession extends Model
1415
{
16+
use HasFactory;
17+
1518
/**
1619
* The attributes that should be casted to native types.
1720
*

app/ApiToken.php

+3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
namespace Biigle;
44

5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
56
use Illuminate\Database\Eloquent\Model;
67

78
class ApiToken extends Model
89
{
10+
use HasFactory;
11+
912
/**
1013
* The attributes excluded from the model's JSON form.
1114
*

app/Console/Kernel.php

-9
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@
1010

1111
class Kernel extends ConsoleKernel
1212
{
13-
/**
14-
* The Artisan commands provided by your application.
15-
*
16-
* @var array
17-
*/
18-
protected $commands = [
19-
//
20-
];
21-
2213
/**
2314
* Define the application's command schedule.
2415
*

app/Exceptions/Handler.php

+12-25
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Handler extends ExceptionHandler
1212
/**
1313
* A list of the exception types that are not reported.
1414
*
15-
* @var array
15+
* @var array<int, class-string<Throwable>>
1616
*/
1717
protected $dontReport = [
1818
//
@@ -21,41 +21,25 @@ class Handler extends ExceptionHandler
2121
/**
2222
* A list of the inputs that are never flashed for validation exceptions.
2323
*
24-
* @var array
24+
* @var array<int, string>
2525
*/
2626
protected $dontFlash = [
27+
'current_password',
2728
'password',
2829
'password_confirmation',
2930
'auth_password',
3031
];
3132

3233
/**
33-
* Report or log an exception.
34+
* Register the exception handling callbacks for the application.
3435
*
35-
* @param Throwable $exception
3636
* @return void
3737
*/
38-
public function report(Throwable $e)
38+
public function register()
3939
{
40-
parent::report($e);
41-
}
42-
43-
/**
44-
* Render an exception into an HTTP response.
45-
*
46-
* @param \Illuminate\Http\Request $request
47-
* @param Throwable $e
48-
* @return \Illuminate\Http\Response
49-
*/
50-
public function render($request, Throwable $e)
51-
{
52-
// Convert the exception here because we want to throw a 403 and not a 500.
53-
// Also set a helpful error message for the user.
54-
if ($e instanceof TokenMismatchException) {
55-
$e = new TokenMismatchException('Your user session expired. Please refresh the page.');
56-
}
57-
58-
return parent::render($request, $e);
40+
$this->reportable(function (Throwable $e) {
41+
//
42+
});
5943
}
6044

6145
/**
@@ -66,7 +50,10 @@ public function render($request, Throwable $e)
6650
*/
6751
protected function prepareException(Throwable $e)
6852
{
69-
if ($e instanceof MethodNotAllowedHttpException) {
53+
if ($e instanceof TokenMismatchException) {
54+
// Set a helpful error message for the user.
55+
$e = new TokenMismatchException('Your user session expired. Please refresh the page.');
56+
} elseif ($e instanceof MethodNotAllowedHttpException) {
7057
// Add a helpful message to this exception.
7158
$allow = explode(', ', $e->getHeaders()['Allow']);
7259
$e = new MethodNotAllowedHttpException($allow, 'The HTTP method is not allowed.', $e);

app/FederatedSearchInstance.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
use Illuminate\Auth\Authenticatable;
66
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
7+
use Illuminate\Database\Eloquent\Factories\HasFactory;
78
use Illuminate\Database\Eloquent\Model;
89
use Illuminate\Support\Str;
910

1011
class FederatedSearchInstance extends Model implements AuthenticatableContract
1112
{
12-
use Authenticatable;
13+
use Authenticatable, HasFactory;
1314

1415
/**
1516
* The attributes that are mass assignable.

app/FederatedSearchModel.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
namespace Biigle;
44

55
use Biigle\Traits\HasJsonAttributes;
6+
use Illuminate\Database\Eloquent\Factories\HasFactory;
67
use Illuminate\Database\Eloquent\Model;
78

89
class FederatedSearchModel extends Model
910
{
10-
use HasJsonAttributes;
11+
use HasJsonAttributes, HasFactory;
1112

1213
/**
1314
* The attributes that should be casted to native types.

app/Http/Controllers/Auth/LoginController.php

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Biigle\Http\Controllers\Controller;
66
use Illuminate\Foundation\Auth\AuthenticatesUsers;
7+
use Illuminate\Foundation\Auth\ThrottlesLogins;
78
use Illuminate\Http\Request;
89

910
class LoginController extends Controller
@@ -19,6 +20,7 @@ class LoginController extends Controller
1920
|
2021
*/
2122

23+
// use ThrottlesLogins;
2224
use AuthenticatesUsers {
2325
credentials as protected baseCredentials;
2426
attemptLogin as protected baseAttemptLogin;

app/Http/Kernel.php

+6-7
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ class Kernel extends HttpKernel
1111
*
1212
* These middleware are run during every request to your application.
1313
*
14-
* @var array
14+
* @var array<int, class-string|string>
1515
*/
1616
protected $middleware = [
1717
// If this is ever enabled, also enable TrustHosts.
1818
// see: https://github.com/laravel/laravel/pull/5477
1919
// \Biigle\Http\Middleware\TrustHosts::class,
2020
// \Biigle\Http\Middleware\TrustProxies::class,
2121
\Fruitcake\Cors\HandleCors::class,
22-
\Biigle\Http\Middleware\CheckForMaintenanceMode::class,
22+
\Biigle\Http\Middleware\PreventRequestsDuringMaintenance::class,
2323
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
2424
\Biigle\Http\Middleware\TrimStrings::class,
2525
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
@@ -28,7 +28,7 @@ class Kernel extends HttpKernel
2828
/**
2929
* The application's route middleware groups.
3030
*
31-
* @var array
31+
* @var array<string, array<int, class-string|string>>
3232
*/
3333
protected $middlewareGroups = [
3434
'web' => [
@@ -43,8 +43,8 @@ class Kernel extends HttpKernel
4343
],
4444

4545
'api' => [
46-
'throttle:60,1',
47-
'bindings',
46+
'throttle:api',
47+
\Illuminate\Routing\Middleware\SubstituteBindings::class,
4848
],
4949
];
5050

@@ -53,13 +53,12 @@ class Kernel extends HttpKernel
5353
*
5454
* These middleware may be assigned to groups or used individually.
5555
*
56-
* @var array
56+
* @var array<string, class-string|string>
5757
*/
5858
protected $routeMiddleware = [
5959
'auth' => \Biigle\Http\Middleware\Authenticate::class,
6060
// 'auth.api' => \Biigle\Http\Middleware\AuthenticateAPI::class,
6161
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
62-
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
6362
'can' => \Illuminate\Auth\Middleware\Authorize::class,
6463
'guest' => \Biigle\Http\Middleware\RedirectIfAuthenticated::class,
6564
'session' => \Biigle\Http\Middleware\SessionOnly::class,

app/Http/Middleware/EncryptCookies.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class EncryptCookies extends Middleware
99
/**
1010
* The names of the cookies that should not be encrypted.
1111
*
12-
* @var array
12+
* @var array<int, string>
1313
*/
1414
protected $except = [
1515
//

app/Http/Middleware/CheckForMaintenanceMode.php app/Http/Middleware/PreventRequestsDuringMaintenance.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
namespace Biigle\Http\Middleware;
44

5-
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
5+
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
66

7-
class CheckForMaintenanceMode extends Middleware
7+
class PreventRequestsDuringMaintenance extends Middleware
88
{
99
/**
1010
* The URIs that should be reachable while maintenance mode is enabled.
1111
*
12-
* @var array
12+
* @var array<int, string>
1313
*/
1414
protected $except = [
1515
//

app/Http/Middleware/RedirectIfAuthenticated.php

+12-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace Biigle\Http\Middleware;
44

5+
use Biigle\Providers\RouteServiceProvider;
56
use Closure;
7+
use Illuminate\Http\Request;
68
use Illuminate\Support\Facades\Auth;
79

810
class RedirectIfAuthenticated
@@ -11,14 +13,18 @@ class RedirectIfAuthenticated
1113
* Handle an incoming request.
1214
*
1315
* @param \Illuminate\Http\Request $request
14-
* @param \Closure $next
15-
* @param string|null $guard
16-
* @return mixed
16+
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
17+
* @param string|null ...$guards
18+
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
1719
*/
18-
public function handle($request, Closure $next, $guard = null)
20+
public function handle(Request $request, Closure $next, ...$guards)
1921
{
20-
if (Auth::guard($guard)->check()) {
21-
return redirect(route('home'));
22+
$guards = empty($guards) ? [null] : $guards;
23+
24+
foreach ($guards as $guard) {
25+
if (Auth::guard($guard)->check()) {
26+
return redirect(RouteServiceProvider::HOME);
27+
}
2228
}
2329

2430
return $next($request);

0 commit comments

Comments
 (0)