mirror of
https://github.com/robonen/education-project.git
synced 2026-03-20 02:44:31 +00:00
Правки после слияния
This commit is contained in:
53
app/Filters/JournalFilter.php
Normal file
53
app/Filters/JournalFilter.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filters;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class JournalFilter extends QueryFilter
|
||||
{
|
||||
|
||||
protected function student($value)
|
||||
{
|
||||
$this->builder = $this->builder->where('student_id', $value);
|
||||
}
|
||||
|
||||
protected function teacher($value)
|
||||
{
|
||||
$this->builder = $this->builder->where('teacher_id', $value);
|
||||
}
|
||||
|
||||
protected function subject($value)
|
||||
{
|
||||
$this->builder = $this->builder->where('subject_id', $value);
|
||||
}
|
||||
|
||||
protected function start($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);
|
||||
$this->builder = $this->builder->where('updated_at', '>=', $date);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user