DashboardController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
eloc 15
c 3
b 0
f 0
dl 0
loc 31
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 26 4
1
<?php
2
3
namespace App\Http\Controllers\Home;
4
5
use Inertia\Inertia;
6
use Illuminate\Http\Request;
7
8
use App\Http\Controllers\Controller;
9
use App\Models\UserCustomerBookmark;
10
use App\Models\UserTechTipBookmark;
11
use Illuminate\Support\Facades\Auth;
12
use Nwidart\Modules\Facades\Module;
13
14
class DashboardController extends Controller
15
{
16
    /**
17
     *  Landing page for authorized users
18
     */
19
    public function __invoke(Request $request)
20
    {
21
        //  Determine if there are any Dashboard Tools that need to be loaded
22
        $modules = Module::allEnabled();
23
        $tools   = [];
24
        foreach($modules as $module)
25
        {
26
            $name     = $module->getLowerName();
27
            $toolData = config($name.'.dashboard_tool');
28
29
            if($toolData)
30
            {
31
                foreach($toolData as $data)
32
                {
33
                    $tools[] = $data;
34
                }
35
            }
36
        }
37
38
        return Inertia::render('Home/Dashboard', [
39
            'notifications' => $request->user()->notifications,
40
            'bookmarks'     => [
41
                'customers' => UserCustomerBookmark::where('user_id', $request->user()->user_id)->get(),
42
                'tips'      => UserTechTipBookmark::where('user_id', $request->user()->user_id)->get(),
43
            ],
44
            'tools'         => $tools,
45
        ]);
46
    }
47
}
48