public function run() { DB::statement('TRUNCATE TABLE t_px_Pfdj CASCADE'); Pfdj::create(array('mc' => '优秀', 'zdfz' => 90, 'zgfz' => 100)); Pfdj::create(array('mc' => '良好', 'zdfz' => 80, 'zgfz' => 89)); Pfdj::create(array('mc' => '中等', 'zdfz' => 70, 'zgfz' => 79)); Pfdj::create(array('mc' => '合格', 'zdfz' => 60, 'zgfz' => 69)); Pfdj::create(array('mc' => '不合格', 'zdfz' => 0, 'zgfz' => 59)); }
public function getExportStatisticsByMajor($year, $term) { $results = $this->retrieveStatisticsResultsByMajor($year, $term); $sheetName = $year . '~' . ($year + 1) . '学年度' . Term::find($term)->mc . '学期教师评学分专业统计表'; $datas[0] = ['专业', '年级', '总分', '等级']; foreach ($results as $result) { $row = array(); $row[] = $result->zymc; $row[] = $result->nj; $row[] = number_format($result->total, 2); if (!is_null($result->total)) { $row[] = Pfdj::where('zdfz', '<=', floor($result->total))->where('zgfz', '>=', floor($result->total))->first()->mc; } else { $row[] = null; } $datas[] = $row; } Excel::create('export', function ($excel) use($sheetName, $datas) { $excel->setTitle('Guangxi Normal University Teacher Evaludate Students Statistics Report'); $excel->setCreator('Dean')->setCompany('Guangxi Normal University'); $excel->sheet($sheetName, function ($sheet) use($datas) { $sheet->setOrientation('landscape'); $sheet->fromArray($datas, null, 'A1', false, false); }); })->export('xls'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function deleteDelete($id) { $pfdj = Pfdj::find($id); if (is_null($pfdj)) { return back()->withErrors('没有找到评分等级'); } elseif ($pfdj->delete()) { return redirect('pfdj/list')->with('status', '评分等级删除成功'); } else { return back()->withErrors('评分等级删除失败'); } }