From e244c87c645fb2bf995458f4c5db6820c1d02ebb Mon Sep 17 00:00:00 2001 From: MaZen Date: Sun, 18 Aug 2024 06:09:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=83=A8=E5=88=86=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Metrics/Examples/ReportRate.php | 128 ++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 app/Admin/Metrics/Examples/ReportRate.php diff --git a/app/Admin/Metrics/Examples/ReportRate.php b/app/Admin/Metrics/Examples/ReportRate.php new file mode 100644 index 0000000..7787dae --- /dev/null +++ b/app/Admin/Metrics/Examples/ReportRate.php @@ -0,0 +1,128 @@ +title('新生总报道率'); + + } + + /** + * 处理请求. + * + * @param Request $request + * + * @return void + */ + public function handle(Request $request) + { + + //取出当前年份 + $config = Config::query()->where([ + "unique_identification" => "annual_session" + ])->first(); + + //当前年份已完成二级学院扫码的学生 + $allCount = CompletedOfflineStep::query()->where([ + "annual_session" => $config->data, + ])->select("unique_number")->distinct()->get(); + + $this->content($allCount); + + if($allCount > 0){ + $this->up($allCount); + }else{ + $this->down($allCount); + } + + } + + /** + * @param int $percent + * + * @return $this + */ + public function up($percent) + { + return $this->footer( + " {$percent}人 为当前年份已分配床位数" + ); + } + + /** + * @param int $percent + * + * @return $this + */ + public function down($percent) + { + return $this->footer( + " {$percent}人 为当前年份已分配床位数" + ); + } + + /** + * 设置卡片底部内容. + * + * @param string|Renderable|\Closure $footer + * + * @return $this + */ + public function footer($footer) + { + $this->footer = $footer; + + return $this; + } + + /** + * 渲染卡片内容. + * + * @return string + */ + public function renderContent() + { + $content = parent::renderContent(); + + return << +

{$content}

+ +
+ {$this->renderFooter()} +
+HTML; + } + + /** + * 渲染卡片底部内容. + * + * @return string + */ + public function renderFooter() + { + return $this->toString($this->footer); + } +}