__('Business_type 1'), '2' => __('Business_type 2')]; } public function getExamineStatusList() { return ['0' => __('Examine_status 0'), '1' => __('Examine_status 1')]; } public function getPayStatusList() { return ['0' => __('Pay_status 0'), '1' => __('Pay_status 1'), '2' => __('Pay_status 2')]; } public function getCustomersList(){ return (new Customers())->where(['status'=>1])->select(); } public function getSuppliersList(){ return (new Suppliers())->where(['status'=>1])->select(); } public function getIncomeTypeList(){ return (new IncomeType())->where(['status'=>1])->select(); } public function getAccountsList(){ return (new Accounts())->where(['status'=>1])->select(); } public function getPurchaseTimeTextAttr($value, $data) { $value = $value ? $value : (isset($data['purchase_time']) ? $data['purchase_time'] : ''); return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } public function getBusinessTypeTextAttr($value, $data) { $value = $value ? $value : (isset($data['business_type']) ? $data['business_type'] : ''); $list = $this->getBusinessTypeList(); return isset($list[$value]) ? $list[$value] : ''; } public function getExamineStatusTextAttr($value, $data) { $value = $value ? $value : (isset($data['examine_status']) ? $data['examine_status'] : ''); $list = $this->getExamineStatusList(); return isset($list[$value]) ? $list[$value] : ''; } public function getExamineTimeTextAttr($value, $data) { $value = $value ? $value : (isset($data['examine_time']) ? $data['examine_time'] : ''); return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } public function getPayStatusTextAttr($value, $data) { $value = $value ? $value : (isset($data['pay_status']) ? $data['pay_status'] : ''); $list = $this->getPayStatusList(); return isset($list[$value]) ? $list[$value] : ''; } protected function setPurchaseTimeAttr($value) { return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); } protected function setExamineTimeAttr($value) { return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); } public function customers() { return $this->belongsTo('Customers', 'customers_id', 'id', [], 'LEFT')->setEagerlyType(0); } public function admin() { return $this->belongsTo('app\admin\model\Admin', 'preparation_id', 'id', [], 'LEFT')->setEagerlyType(0); } public function examine() { return $this->belongsTo('app\admin\model\Admin', 'examine_id', 'id', [], 'LEFT')->setEagerlyType(0); } }