Fixes For GDPR/Deleted Users (#1164)

* Fix DeletedUsers being displayed at Homepage

Deleted users should not be displayed at homepage / newest pilots list. PR fixes that problem.

* Do Not Display Deleted Users with LatestPireps

As the main page, Latest Pilots widget should not display GDPR/Soft deleted users too.

* StyleFix
This commit is contained in:
B.Fatih KOZ 2021-05-03 15:46:21 +03:00 committed by GitHub
parent ec6cb42bfd
commit 5094375e13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -3,6 +3,7 @@
namespace App\Http\Controllers\Frontend;
use App\Contracts\Controller;
use App\Models\Enums\UserState;
use App\Models\User;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Log;
@ -15,7 +16,7 @@ class HomeController extends Controller
public function index()
{
try {
$users = User::orderBy('created_at', 'desc')->take(4)->get();
$users = User::where('state', '!=', UserState::DELETED)->orderBy('created_at', 'desc')->take(4)->get();
} catch (\PDOException $e) {
Log::emergency($e);
return view('system/errors/database_error', [

View File

@ -3,6 +3,7 @@
namespace App\Widgets;
use App\Contracts\Widget;
use App\Models\Enums\UserState;
use App\Repositories\UserRepository;
/**
@ -20,10 +21,11 @@ class LatestPilots extends Widget
public function run()
{
$userRepo = app(UserRepository::class);
$userRepo = $userRepo->where('state', '!=', UserState::DELETED)->orderby('created_at', 'desc')->take($this->config['count'])->get();
return view('widgets.latest_pilots', [
'config' => $this->config,
'users' => $userRepo->with(['airline'])->recent($this->config['count']),
'users' => $userRepo,
]);
}
}