fix: 家长下载课表报错
This commit is contained in:
parent
b8aa08b285
commit
eae7394952
@ -3,10 +3,12 @@
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\model\Student;
|
||||
use app\common\model\StudentSchedule;
|
||||
use app\common\service\StudentService;
|
||||
use app\constant\ResponseCode;
|
||||
use support\Request;
|
||||
use think\Exception;
|
||||
|
||||
class StudentController extends BaseController
|
||||
{
|
||||
@ -96,9 +98,22 @@ class StudentController extends BaseController
|
||||
public function downloadSchedule(Request $request)
|
||||
{
|
||||
|
||||
if (!empty((array)$request->student)) {
|
||||
$student = Student::where(['id' => $request->student->id])->findOrEmpty();
|
||||
if ($student->isEmpty()) {
|
||||
throw new Exception('未找到用户信息');
|
||||
}
|
||||
}
|
||||
if (!empty((array)$request->parent)) {
|
||||
$student = Student::where(['parent_id' => $request->parent->id])->findOrEmpty();
|
||||
if ($student->isEmpty()) {
|
||||
throw new Exception('未找到用户信息');
|
||||
}
|
||||
}
|
||||
|
||||
$request_data = $request->post();
|
||||
$month = date('Y-m', strtotime($request_data['date']));
|
||||
$student_schedule = StudentSchedule::where(['student_id' => $request->student->id, 'is_publish' => 1])
|
||||
$student_schedule = StudentSchedule::where(['student_id' => $student->id, 'is_publish' => 1])
|
||||
->where(['month' => $month])
|
||||
->with(['teacher', 'subject'])
|
||||
->order('start_time asc')
|
||||
@ -126,7 +141,7 @@ class StudentController extends BaseController
|
||||
'table_time' => $month,
|
||||
'data' => $array,
|
||||
];
|
||||
$file_path = '/files/images/student_schedule/' . $month . "/{$request->student->id}/";
|
||||
$file_path = '/files/images/student_schedule/' . $month . "/{$student->id}/";
|
||||
$base = [
|
||||
'border' => 10,//图片外边框
|
||||
'file_path' => public_path($file_path),//图片保存路径
|
||||
|
@ -341,7 +341,7 @@ class SubjectHomeworkController extends Crud
|
||||
|
||||
|
||||
/**
|
||||
* @desc 更改课程报告发布状态
|
||||
* @desc 更改课程发布状态
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user