mirror of
https://github.com/robonen/education-project.git
synced 2026-03-20 02:44:31 +00:00
Merge branch 'timetable' of github.com:Robonen/education-project into timetable
This commit is contained in:
@@ -23,12 +23,27 @@ class JournalFilter extends QueryFilter
|
||||
$this->builder = $this->builder->where('subject_id', $value);
|
||||
}
|
||||
|
||||
protected function date($value)
|
||||
protected function start($value)
|
||||
{
|
||||
$value = Carbon::createFromTimestamp($value/1000)->floorDays();
|
||||
$this->builder = $this->builder->where('updated_at', $value);
|
||||
$this->builder = $this->builder->where('updated_at', '>=', $this->transformDate($value));
|
||||
}
|
||||
|
||||
protected function end($value)
|
||||
{
|
||||
$this->builder = $this->builder->where('updated_at', '<=', $this->transformDate($value));
|
||||
}
|
||||
|
||||
protected function transformDate($value)
|
||||
{
|
||||
return Carbon::createFromTimestamp($value/1000)->floorDays();;
|
||||
}
|
||||
|
||||
// protected function date($value)
|
||||
// {
|
||||
// $value = Carbon::createFromTimestamp($value/1000)->floorDays();
|
||||
// $this->builder = $this->builder->where('updated_at', $value);
|
||||
// }
|
||||
|
||||
protected function last($value)
|
||||
{
|
||||
$date = Carbon::now()->subDays($value);
|
||||
|
||||
@@ -47,14 +47,14 @@ class TimetableController extends Controller
|
||||
}
|
||||
|
||||
$dateTimetables = [];
|
||||
if (!$filterTimetables->isEmpty()) {
|
||||
//if (!$filterTimetables->isEmpty()) {
|
||||
for ($i = 0; $i < 6; $i++) {
|
||||
$date = Carbon::parse($request->input('date'))
|
||||
->startOfWeek()
|
||||
->addDays($i)
|
||||
->format('Y-m-d');
|
||||
array_push($dateTimetables, [$date => $filterTimetables->where('date', $date)->values()]);
|
||||
}
|
||||
// }
|
||||
}
|
||||
return response()->json($dateTimetables, 200);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Http\Requests\StudentRequest;
|
||||
use App\Models\SchoolClass;
|
||||
use App\Models\Student;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Models\AnswerToTask;
|
||||
|
||||
class StudentController extends Controller
|
||||
{
|
||||
@@ -66,7 +67,17 @@ class StudentController extends Controller
|
||||
return response()->json(collect($student)->except('school_class'), 200);
|
||||
}
|
||||
|
||||
|
||||
public function destroy(Student $student)
|
||||
{
|
||||
$user = $student->user;
|
||||
$user->delete();
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
|
||||
|
||||
public function getAnswers(Student $student) {
|
||||
return AnswerToTask::where('student_id', '=', $student->id)->get();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,14 +26,18 @@ class SchoolClass extends Model
|
||||
->withPivot('hours_per_week', 'hours_per_year');
|
||||
}
|
||||
|
||||
public function chatLinks()
|
||||
{
|
||||
return $this->hasMany(ChatLink::class, 'class_id');
|
||||
}
|
||||
|
||||
|
||||
public function tasks() {
|
||||
return $this->hasMany(Task::class, 'class_id');
|
||||
}
|
||||
|
||||
|
||||
public function chatLinks()
|
||||
{
|
||||
return $this->hasMany(ChatLink::class, 'class_id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,9 @@ class Teacher extends Model
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
|
||||
public function tasks(){
|
||||
return $this->hasMany(Task::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user