@yield('title', lang('loan_car_model.name'))

@section('breadcrumb')
	<h2>@lang('loan_car_model.name')</h2>
	<h3><a href="{{ route('create') }}">@lang('master.add_bt')</a></h3>
@endsection

@extension('message')

@php
	$extensionOption = [
		'name' => 'table-loan-car',
		'title' => 'loan-car',
		'controller_url' => route('index'),
		'min_width' => '1600px',
		'column_width' => [
			'code' => '180px',
			'borrower' => '250px',
			'type' => '90px'
		],
		'filter_control' => [
			[
				'type' => 'attr',
				'column' => 'status',
				'option_text' => lang('loan_car_model.status'),
				'data' => [
					1 => lang('loan_car_model.free'),
					2 => lang('loan_car_model.busy'),
					3 => lang('loan_car_model.lost'),
				]
			]
		],
		'action_link' => [
			'status' => [
				'format' => function($value) {
					if($value['status'] == 2) {
						return '<a href="' . route('status', ['id' => $value['id'], 'status' => 1]) . '">Trả xe</a>';
					}

					if($value['status'] == 3) {
						return '<a href="' . route('status', ['id' => $value['id'], 'status' => 1]) . '">Đã tìm thấy</a>';
					}
					return '';
				},
				'display_in' => 'table-row'
			]
		],
		'custom_value_column' => [
			'type' => function($value) {
				if($value['type'] == 1)
					return lang('loan_car_model.motorcycle');

				if($value['type'] == 2)
					return lang('loan_car_model.oto');

				if($value['type'] == 3)
					return lang('loan_car_model.truck');

				if($value['type'] == 4)
					return lang('loan_car_model.bike');
			},
			'status' => function($value) {
				if($value['status'] == 1)
					return lang('loan_car_model.free');

				if($value['status'] == 2)
					return lang('loan_car_model.busy');

				if($value['status'] == 3)
					return lang('loan_car_model.lost');
			}
		]
	];
@endphp

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