| xqd
@@ -435,6 +435,12 @@ class ApiController extends Controller
|
|
|
if(empty($request->input('type')) || !in_array($request->input('type'), [1, 2])) {
|
|
|
return response()->json(['status' => 'fail', 'info' => '找不到学员']);
|
|
|
}
|
|
|
+ if($request->input('type') == 1 && $student->short_leave_times <= 0) {
|
|
|
+ return response()->json(['status' => 'fail', 'info' => '短假次数达到上限']);
|
|
|
+ }
|
|
|
+ if($request->input('type') == 2 && $student->long_leave_times <= 0) {
|
|
|
+ return response()->json(['status' => 'fail', 'info' => '长假次数达到上限']);
|
|
|
+ }
|
|
|
$student_course = StudentCourse::where('student_id', $student->id)->first();
|
|
|
if(empty($student_course)) {
|
|
|
return response()->json(['status' => 'fail', 'info' => '暂无课程']);
|
| xqd
@@ -451,6 +457,14 @@ class ApiController extends Controller
|
|
|
if(!$res) {
|
|
|
return response()->json(['status' => 'fail', 'info' => '保存失败']);
|
|
|
}
|
|
|
+ if($request->input('type') == 1) {
|
|
|
+ $student->short_leave_times -= 1;
|
|
|
+ $student->save();
|
|
|
+ }
|
|
|
+ if($request->input('type') == 2) {
|
|
|
+ $student->long_leave_times -= 1;
|
|
|
+ $student->save();
|
|
|
+ }
|
|
|
return response()->json(['status' => 'success', 'info' => '请假成功']);
|
|
|
}
|
|
|
|