blob: b3c84433824f19494109f3a1b71b5f6d9768d6dc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
<?php
namespace App\Http\Controllers;
use Auth;
use Illuminate\Foundation\Auth\User;
class AdminController extends Controller
{
public function Dashboard()
{
$this->checkAdmin();
return view('admin.dashboard', [
'user' => Auth::user(),
'cpu_load' => round(sys_getloadavg()[1]/(trim(shell_exec("grep -P '^processor' /proc/cpuinfo|wc -l")) + 1)*100, 0)
]);
}
private function checkAdmin()
{
$isAdmin = User::findOrFail(Auth::user()->id)->admin;
if ($isAdmin !== 1) {
abort(403, 'Sorry, you are not an administrator.');
}
return true;
}
}
|