Completed
Push — master ( f9282d...b5d17f )
by Jeremy
21:36
created

AdminController::filemanager()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 14
rs 10
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Models\Sound;
6
use App\Models\Theme;
7
use App\Models\User;
8
9
class AdminController extends Controller
10
{
11
    /**
12
     * Create a new controller instance.
13
     *
14
     * @return void
15
     */
16
    public function __construct()
17
    {
18
        $this->middleware('auth');
19
    }
20
21
    /**
22
     * Show the application dashboard.
23
     *
24
     * @return \Illuminate\View\View
25
     */
26
    public function index()
27
    {
28
        $sounds = Sound::sortedSounds()->get();
29
        $enabledSounds = Sound::enabledSounds()->sortedSounds()->get();
30
        $user = auth()->user();
31
        $users = User::all();
32
        $themes = Theme::enabledThemes()->get();
33
34
        $data = [
35
            'sounds'        => $sounds,
36
            'enabledSounds' => $enabledSounds,
37
            'user'          => $user,
38
            'users'         => $users,
39
            'themes'        => $themes,
40
        ];
41
42
        return view('pages.dashboard', $data);
43
    }
44
45
    /**
46
     * Show the application filemanager.
47
     *
48
     * @return \Illuminate\View\View
49
     */
50
    public function filemanager()
51
    {
52
        $uploadedFilePath = "sound-files/";
53
        $uploadfilesNames = collect(scandir($uploadedFilePath));
54
55
        $recordedFilePath = "sound-files/recordings/";
56
        $recordedfilesNames = collect(scandir($recordedFilePath));
57
58
        $data = [
59
            'uploadfilesNames'  => $uploadfilesNames,
60
            'recordedfilesNames'  => $recordedfilesNames,
61
        ];
62
63
        return view('pages.filemanager', $data);
64
    }
65
}
66