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

@section('breadcrumb')
	<h2>@lang('branch_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;
	}

	if(area_name() == 'super-admin') { 
		$filterControl = [[
			'type' => 'column',
			'column' => 'Stores_name',
			'data' => 'table-column',
			'option_text' => lang('store_model.choose_default')
		]];
	} else {
		$filterControl = null;
	}

	$extensionOption = [
		'name' => 'table-branchs',
		'title' => 'branchs',
		'controller_url' => route('index'),
		'before_get_data' => function($model) {
			if(area_name() == 'master') {
				$auth = load_auth();
				$user = $auth->getUser();
				$model->where('storeID', $user->storeID);
			}
		},
		'action_link' => $actionLinks,
		'filter_control' => $filterControl
	];
@endphp

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