From 34f0a3b710a5cd372d5d66e5187a0eefc04f8997 Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Tue, 29 Sep 2020 01:00:28 +0000 Subject: [PATCH 1/2] Adopt Laravel coding style The Laravel framework adopts the PSR-2 coding style with some additions. Laravel apps *should* adopt this coding style as well. However, Shift allows you to customize the adopted coding style by adding your own [PHP CS Fixer][1] `.php_cs` config to your project. You may use [Shift's .php_cs][2] file as a base. [1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer [2]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200 --- app/Http/Middleware/CheckIsUserActivated.php | 4 ++-- app/Logic/Macros/HtmlMacros.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Http/Middleware/CheckIsUserActivated.php b/app/Http/Middleware/CheckIsUserActivated.php index be66c1ce9..824c4e529 100755 --- a/app/Http/Middleware/CheckIsUserActivated.php +++ b/app/Http/Middleware/CheckIsUserActivated.php @@ -39,7 +39,7 @@ public function handle($request, Closure $next) 'welcome', ]; - if (!in_array($currentRoute, $routesAllowed)) { + if (! in_array($currentRoute, $routesAllowed)) { if ($user && $user->activated != 1) { Log::info('Non-activated user attempted to visit '.$currentRoute.'. ', [$user]); @@ -72,7 +72,7 @@ public function handle($request, Closure $next) return redirect('home'); } - if (!$user) { + if (! $user) { Log::info('Non registered visit to '.$currentRoute.'. '); return redirect()->route('welcome'); diff --git a/app/Logic/Macros/HtmlMacros.php b/app/Logic/Macros/HtmlMacros.php index 0529bfb1a..262628b0d 100755 --- a/app/Logic/Macros/HtmlMacros.php +++ b/app/Logic/Macros/HtmlMacros.php @@ -23,7 +23,7 @@ return $link; }); -/** +/* * Render an icon with an anchor tag around it. * * @var string url @@ -44,7 +44,7 @@ return $link; }); -/** +/* * Render an button with an icon with an anchor tag around it. * * @var string url @@ -65,7 +65,7 @@ return $link; }); -/** +/* * Show Username. * * @return string From 8e62c3f4358b2a148cb95736132d1a4c7d27d8a6 Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Tue, 29 Sep 2020 01:00:29 +0000 Subject: [PATCH 2/2] Shift bindings PHP 5.5.9+ adds the new static `class` property which provides the fully qualified class name. This is preferred over using class name strings as these references are checked by the parser. --- app/Models/Activation.php | 2 +- app/Models/Profile.php | 4 ++-- app/Models/Social.php | 2 +- app/Models/Theme.php | 2 +- app/Models/User.php | 6 +++--- app/Providers/ComposerServiceProvider.php | 2 +- routes/web.php | 8 ++++---- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/Models/Activation.php b/app/Models/Activation.php index 1235d6327..9f3f653ef 100755 --- a/app/Models/Activation.php +++ b/app/Models/Activation.php @@ -78,6 +78,6 @@ class Activation extends Model */ public function user() { - return $this->belongsTo('App\Models\User'); + return $this->belongsTo(\App\Models\User::class); } } diff --git a/app/Models/Profile.php b/app/Models/Profile.php index f7f860913..a1701cc3e 100755 --- a/app/Models/Profile.php +++ b/app/Models/Profile.php @@ -49,7 +49,7 @@ class Profile extends Model */ public function user() { - return $this->belongsTo('App\Models\User'); + return $this->belongsTo(\App\Models\User::class); } /** @@ -59,6 +59,6 @@ public function user() */ public function theme() { - return $this->hasOne('App\Models\Theme'); + return $this->hasOne(\App\Models\Theme::class); } } diff --git a/app/Models/Social.php b/app/Models/Social.php index 1d83bb62a..2140c3f02 100755 --- a/app/Models/Social.php +++ b/app/Models/Social.php @@ -74,6 +74,6 @@ class Social extends Model */ public function user() { - return $this->belongsTo('App\Models\User'); + return $this->belongsTo(\App\Models\User::class); } } diff --git a/app/Models/Theme.php b/app/Models/Theme.php index b2c0fd844..8b4ca91f1 100755 --- a/app/Models/Theme.php +++ b/app/Models/Theme.php @@ -106,6 +106,6 @@ public static function rules($id = 0, $merge = []) */ public function profile() { - return $this->hasMany('App\Models\Profile'); + return $this->hasMany(\App\Models\Profile::class); } } diff --git a/app/Models/User.php b/app/Models/User.php index b20bce03d..1da7c2220 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -107,7 +107,7 @@ class User extends Authenticatable */ public function social() { - return $this->hasMany('App\Models\Social'); + return $this->hasMany(\App\Models\Social::class); } /** @@ -115,7 +115,7 @@ public function social() */ public function profile() { - return $this->hasOne('App\Models\Profile'); + return $this->hasOne(\App\Models\Profile::class); } /** @@ -123,7 +123,7 @@ public function profile() */ public function profiles() { - return $this->belongsToMany('App\Models\Profile')->withTimestamps(); + return $this->belongsToMany(\App\Models\Profile::class)->withTimestamps(); } /** diff --git a/app/Providers/ComposerServiceProvider.php b/app/Providers/ComposerServiceProvider.php index ee7fb85cf..24bb02ccd 100755 --- a/app/Providers/ComposerServiceProvider.php +++ b/app/Providers/ComposerServiceProvider.php @@ -16,7 +16,7 @@ public function boot() { View::composer( 'layouts.app', - 'App\Http\ViewComposers\ThemeComposer' + \App\Http\ViewComposers\ThemeComposer::class ); } diff --git a/routes/web.php b/routes/web.php index fec0d2201..ec47b6ffa 100755 --- a/routes/web.php +++ b/routes/web.php @@ -69,7 +69,7 @@ // User Profile and Account Routes Route::resource( 'profile', - 'App\Http\Controllers\ProfilesController', + \App\Http\Controllers\ProfilesController::class, [ 'only' => [ 'show', @@ -103,13 +103,13 @@ // Registered, activated, and is admin routes. Route::group(['middleware' => ['auth', 'activated', 'role:admin', 'activity', 'twostep', 'checkblocked']], function () { - Route::resource('/users/deleted', 'App\Http\Controllers\SoftDeletesController', [ + Route::resource('/users/deleted', \App\Http\Controllers\SoftDeletesController::class, [ 'only' => [ 'index', 'show', 'update', 'destroy', ], ]); - Route::resource('users', 'App\Http\Controllers\UsersManagementController', [ + Route::resource('users', \App\Http\Controllers\UsersManagementController::class, [ 'names' => [ 'index' => 'users', 'destroy' => 'user.destroy', @@ -120,7 +120,7 @@ ]); Route::post('search-users', 'App\Http\Controllers\UsersManagementController@search')->name('search-users'); - Route::resource('themes', 'App\Http\Controllers\ThemesManagementController', [ + Route::resource('themes', \App\Http\Controllers\ThemesManagementController::class, [ 'names' => [ 'index' => 'themes', 'destroy' => 'themes.destroy',