@yield('title', lang('floor_model.list'))

@section('breadcrumb')
	<h2>@lang('floor_model.list')</h2>
	@if($this->hasCreateRole)
		<h3><a href="{{ route('create') }}">@lang('master.add_bt')</a></h3>
	@endif
@endsection

@extension('message')

@php
	$actionLinks = [];
	if(!$this->hasUpdateRole) {
		$actionLinks['update'] = null;
	}

	if(!$this->hasDeleteRole) {
		$actionLinks['delete'] = null;
		$actionLinks['deletes'] = null;
	}

	$extensionOption = [
		'name' => 'table-floors',
		'title' => 'floors',
		'controller_url' => route('index'),
		'before_get_data' => function($model) {
			if(area_name() == 'master') {
				$auth = load_auth();
				$user = $auth->getUser();
				if($auth->hasRole(\RoleGlobal::$role->viewAllBranch)) {
					$model->whereIn('branchID', $user->getBranchsId());
				}
				else {
					$model->where('branchID', $user->branchID);
				}
			}
		},
		'action_link' => $actionLinks,
		'filter_control' => [
			[
				'type' => 'column',
				'column' => 'Branchs_name',
				'data' => 'table-column',
				'option_text' => lang('branch_model.choose_default')
			]
		]
	];
@endphp

@extension('datatable', 'FloorsModel', $extensionOption)