<?php
 namespace VnChocola\Model;
 use TCMS\Model;
 use TCMS\FieldModel;
 use FIELD_DATA_TYPE;
 class LoanCarModel extends Model {
 public $tableName = 'LoanCars';
 public $timestamp = true;
 public function registerField() {
 $this->addField('id', FIELD_DATA_TYPE::STRING);
 $this->addField('code', FIELD_DATA_TYPE::STRING, function(FieldModel $field) {
 $field->required = true;
 $field->displayName = lang('loan_car_model.code');
 }
);
 $this->addField('name', FIELD_DATA_TYPE::STRING, function(FieldModel $field) {
 $field->required = false;
 $field->displayName = lang('loan_car_model.name_display');
 }
);
 $this->addField('borrower', FIELD_DATA_TYPE::STRING, function(FieldModel $field) {
 $field->required = false;
 $field->displayName = lang('loan_car_model.borrower');
 $field->description = lang('loan_car_model.borrower_desc');
 }
);
 $this->addField('type', FIELD_DATA_TYPE::STRING, function(FieldModel $field) {
 $field->required = false;
 $field->displayName = lang('loan_car_model.type_display');
 $field->setDataSource([ [ 'text' => lang('loan_car_model.motorcycle'), 'id' => 1 ], [ 'text' => lang('loan_car_model.oto'), 'id' => 2 ], [ 'text' => lang('loan_car_model.truck'), 'id' => 3 ], [ 'text' => lang('loan_car_model.bike'), 'id' => 4 ], ], 'text');
 }
);
 $this->addField('status', FIELD_DATA_TYPE::INTEGER, function(FieldModel $field) {
 $field->required = false;
 $field->defaultValue = 1;
 $field->displayName = lang('loan_car_model.status');
 $field->setDataSource([ [ 'text' => lang('loan_car_model.free'), 'id' => 1 ], [ 'text' => lang('loan_car_model.busy'), 'id' => 2 ], [ 'text' => lang('loan_car_model.lost'), 'id' => 3 ] ], 'text');
 }
);
 $this->addField('branchID', FIELD_DATA_TYPE::SELECT, function(FieldModel $field) {
 $field->required = true;
 $field->extension = 'chocola-select';
 $field->extensionOption = [ 'key' => 'storeID' ];
 $field->setDataSource('BranchsModel', 'name', 'id', lang('branch_model.choose_default'));
 $field->displayName = lang('branch_model.name');
 }
);
 $this->addField('chassis', FIELD_DATA_TYPE::STRING, function(FieldModel $field) {
 $field->required = false;
 $field->displayName = lang('loan_car_model.chassis');
 }
);
 $this->addField('color', FIELD_DATA_TYPE::STRING, function(FieldModel $field) {
 $field->required = false;
 $field->displayName = lang('loan_car_model.color_display');
 }
);
 $this->addField('car_model', FIELD_DATA_TYPE::STRING, function(FieldModel $field) {
 $field->required = false;
 $field->displayName = lang('loan_car_model.carmodel_display');
 }
);
 $this->addField('car_model', FIELD_DATA_TYPE::STRING, function(FieldModel $field) {
 $field->required = false;
 $field->displayName = lang('loan_car_model.carmodel_display');
 }
);
 }
 }
