AdminController   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 6
Bugs 0 Features 0
Metric Value
wmc 5
eloc 15
c 6
b 0
f 0
dl 0
loc 32
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A indexAction() 0 21 5
1
<?php
2
3
/**
4
 * @license MIT, http://opensource.org/licenses/MIT
5
 * @copyright Aimeos (aimeos.org), 2014-2016
6
 * @package laravel
7
 * @subpackage Controller
8
 */
9
10
11
namespace Aimeos\Shop\Controller;
12
13
use Illuminate\Routing\Controller;
14
use Illuminate\Support\Facades\Auth;
15
use Illuminate\Support\Facades\Request;
16
use Illuminate\Support\Facades\Route;
17
use Illuminate\Support\Facades\View;
18
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
19
20
21
/**
22
 * Controller providing the ExtJS administration interface
23
 *
24
 * @package laravel
25
 * @subpackage Controller
26
 */
27
class AdminController extends Controller
28
{
29
	use AuthorizesRequests;
30
31
32
	/**
33
	 * Returns the initial HTML view for the admin interface.
34
	 *
35
	 * @param \Illuminate\Http\Request $request Laravel request object
36
	 * @return \Illuminate\Contracts\View\View View for rendering the output
37
	 */
38
	public function indexAction( \Illuminate\Http\Request $request )
39
	{
40
		if( Auth::check() === false
41
			|| $request->user()->can( 'admin', [AdminController::class, ['admin', 'editor']] ) === false
42
		) {
43
			return redirect()->guest( 'login' );
44
		}
45
46
		$siteId = $request->user()->siteid;
47
		$context = app( 'aimeos.context' )->get( false );
48
		$siteManager = \Aimeos\MShop::create( $context, 'locale/site' );
49
		$siteCode = ( $siteId ? $siteManager->getItem( $siteId )->getCode() : 'default' );
50
		$locale = $request->user()->langid ?: config( 'app.locale', 'en' );
51
52
		$param = array(
53
			'resource' => 'dashboard',
54
			'site' => Route::input( 'site', Request::get( 'site', $siteCode ) ),
55
			'lang' => Route::input( 'lang', Request::get( 'lang', $locale ) )
56
		);
57
58
		return redirect()->route( 'aimeos_shop_jqadm_search', $param );
59
	}
60
}
61