'ID', 'code' => 'ID', 'type' => 'Loại', 'name' => 'Tên', 'image' => 'Hình ảnh đăng kí', 'gender' => 'Giới tính', 'birthday' => 'Ngày sinh', 'telephone' => 'Điện thoại', 'address' => 'Đơn vị', 'time' => 'Thời gian đăng kí', 'last_modified' => 'Last Modified' ]; } public function create($data) { $r = $this->load([ 'code' => $data['code'], 'type' => $data['type'], 'name' => $data['name'], 'image' => $data['image'], 'gender' => $data['gender'], 'birthday' => $data['birthday'] === "" ? 0 : date_format(date_create_from_format('d/m/Y', $data['birthday']), 'U'), 'telephone' => $data['telephone'], 'address' => $data['address'], 'time' => time(), 'last_modified' => time() ], ''); if ($r) { try { $this->save(); return $this->id; } catch (\Exception $ex) { return false; } } } public static $typeArray = [ "wl" => "Whitelist", "bl" => "Blacklist" ]; public static $genderArray = [ "Male" => "Nam", "Female" => "Nữ" ]; public static function nameArray() { $res = [""]; $ls = self::find()->all(); foreach ($ls as $key => $value) { $res[] = $value->name; } return $res; } public static function getAllID() { $res = []; $ls = self::find()->all(); foreach ($ls as $key => $value) { $res[] = $value->code; } return $res; } public static function staffArray() { $res = []; $ls = self::find()->all(); foreach ($ls as $key => $value) { $res[$value->code] = $value->code . " - " . $value->name; } return $res; } public function getAllFeatures() { $features = json_decode($this->image, true); $f = []; foreach ($features as $k => $v) { $f[] = $v['features']; if (isset($v['features512'])) if (count($v['features512'])) $f[] = $v['features512']; } return $f; } public static function statisticFeatures() { $lists = self::find()->all(); $total128 = $total512 = $totalImg = $img = 0; foreach ($lists as $key => $value) { $images = json_decode($value->image, true); if (count($images) > 0) $totalImg++; $img += count($images); foreach ($images as $k => $v) { if (isset($v['features']) && count($v['features']) > 0) $total128++; if (isset($v['features512']) && count($v['features512']) > 0) $total512++; } } return [ "total" => count($lists), "totalImg" => $totalImg, "img" => $img, "128" => $total128, "512" => $total512 ]; } }