2017-06-09 02:28:26 +08:00
|
|
|
<?php
|
|
|
|
|
2018-01-12 11:35:03 +08:00
|
|
|
namespace App\Http\Controllers\Frontend;
|
2017-06-09 02:28:26 +08:00
|
|
|
|
2019-07-16 03:44:31 +08:00
|
|
|
use App\Contracts\Controller;
|
2018-01-12 11:35:03 +08:00
|
|
|
use App\Models\User;
|
2018-02-21 12:33:09 +08:00
|
|
|
use Illuminate\Database\QueryException;
|
2019-05-11 08:31:11 +08:00
|
|
|
use Log;
|
2017-06-09 02:28:26 +08:00
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
/**
|
|
|
|
* Class HomeController
|
|
|
|
*/
|
2018-01-12 11:35:03 +08:00
|
|
|
class HomeController extends Controller
|
2017-06-09 02:28:26 +08:00
|
|
|
{
|
2017-06-10 04:07:29 +08:00
|
|
|
/**
|
|
|
|
* Show the application dashboard.
|
|
|
|
*/
|
2017-06-09 02:28:26 +08:00
|
|
|
public function index()
|
|
|
|
{
|
2017-12-16 01:22:46 +08:00
|
|
|
try {
|
|
|
|
$users = User::orderBy('created_at', 'desc')->take(4)->get();
|
2019-05-11 08:31:11 +08:00
|
|
|
} catch (\PDOException $e) {
|
|
|
|
Log::emergency($e);
|
|
|
|
return view('system/errors/database_error', [
|
|
|
|
'error' => $e->getMessage(),
|
|
|
|
]);
|
2017-12-16 01:22:46 +08:00
|
|
|
} catch (QueryException $e) {
|
|
|
|
return view('system/errors/not_installed');
|
|
|
|
}
|
|
|
|
|
2019-05-11 08:46:50 +08:00
|
|
|
// No users
|
|
|
|
if (!$users) {
|
|
|
|
return view('system/errors/not_installed');
|
|
|
|
}
|
|
|
|
|
2018-03-12 07:00:42 +08:00
|
|
|
return view('home', [
|
2017-08-10 14:00:08 +08:00
|
|
|
'users' => $users,
|
|
|
|
]);
|
2017-06-09 02:28:26 +08:00
|
|
|
}
|
|
|
|
}
|