Completed
Push — master ( 8f08c7...7bd638 )
by Mohamed
02:25
created

LanguageController::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
namespace Microboard\Http\Controllers;
4
5
use Illuminate\Http\RedirectResponse;
6
use Illuminate\Http\Request;
7
8
class LanguageController extends Controller
9
{
10
    /**
11
     * Handle the incoming request.
12
     *
13
     * @param Request $request
14
     * @param $code
15
     * @return RedirectResponse
16
     */
17
    public function __invoke(Request $request, $code)
18
    {
19
        if (in_array($code, collect(config('microboard.localizations', []))->pluck('code')->all())) {
20
            app()->setLocale($code);
21
            session()->put('locale', $code);
22
        }
23
24
        return redirect()->back();
25
    }
26
}
27