'integer', 'account_type' => 'integer', 'belong_id' => 'integer', 'rank' => 'integer', 'status' => 'integer']; public static function list(int $belong_id, int $account_type, string $post_name, bool $export = false): array { $model = self::where('belong_id', $belong_id) ->where('account_type', $account_type); if ($post_name != '') { $model = $model->where('post_name', "like", "%$post_name%"); } $model = $model->orderByDesc("rank")->orderByDesc("post_id") ->select(["post_id", "post_name", "rank", "status", "create_time"]); if (!$export) { // 非导出数据 return $model->get()->toArray(); } $header = ['岗位名称', '状态', '创建时间']; $data = []; foreach ($model->get() as $row) { $data[] = [ $row->post_name, $row->status ? '启用' : '禁用', $row->create_time->format('Y-m-d H:i:s'), ]; } return [$header, $data]; } public static function options(int $belong_id, int $account_type) { return self::where('belong_id', $belong_id) ->where('account_type', $account_type) ->where("status", 1) ->orderByDesc("rank")->orderByDesc("post_id") ->select(["post_id", "post_name"]) ->get()->toArray(); } }