phpvms/app/Http/Controllers/Frontend/HomeController.php
B.Fatih KOZ 5094375e13
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
2021-05-03 08:46:21 -04:00

39 lines
954 B
PHP

<?php
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;
class HomeController extends Controller
{
/**
* Show the application dashboard.
*/
public function index()
{
try {
$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', [
'error' => $e->getMessage(),
]);
} catch (QueryException $e) {
return view('system/errors/not_installed');
}
// No users
if (!$users) {
return view('system/errors/not_installed');
}
return view('home', [
'users' => $users,
]);
}
}