StartController   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 33
rs 10
c 2
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A changeLocale() 0 4 1
A index() 0 7 3
A getLogo() 0 7 2
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Setting;
6
use Illuminate\Support\Facades\Auth;
7
use Illuminate\Support\Facades\Storage;
8
9
class StartController extends Controller
10
{
11
    /**
12
     * Redirect the browser to the appropriate shop site
13
     */
14
    public function index()
15
    {
16
        if (Auth::user() != null && Auth::user()->hasPermission('SELL_TICKETS')) {
17
            return redirect()->route('retail.sell.events');
18
        }
19
20
        return redirect()->route('ts.events');
21
    }
22
23
    /**
24
     * Change the current locale to the given value
25
     */
26
    public function changeLocale($locale)
27
    {
28
        session(['locale' => $locale]);
29
        return redirect()->back();
30
    }
31
32
    /**
33
     * Return the currently stored logo
34
     */
35
    public function getLogo()
36
    {
37
        $logo = Setting::where('name', 'logo')->first();
38
        if( $logo ) {
39
            return response()->file(Storage::path($logo->value));
40
        } else {
41
            return redirect(asset('img/logos/fa-ticket.png'));
42
        }
43
    }
44
}
45