title('待分配床位数'); } /** * 处理请求. * * @param Request $request * * @return void */ public function handle(Request $request) { //取出当前年份 $config = Config::query()->where([ "unique_identification" => "annual_session" ])->first(); //注册总人数 $allCount = SelectedDormitory::query()->where([ "annual_session" => $config->data, "status" => SelectedDormitory::STATUS_YES ])->get()->toArray(); $ids = []; if(!empty($allCount)){ $ids = array_column($allCount, "allocation_dormitory_id"); } $allCount = AllocationDormitoryBed::query()->where([ "annual_session" => $config->data, "status" => AllocationDormitoryBed::STATUS_YES ])->whereNotIn("id", $ids)->count(); $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); } }