BrokerUserConfigFilter.php
1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace App\ModelFilters;
use App\Support\ModelFilter;
use Arr;
class BrokerUserConfigFilter extends ModelFilter
{
public $relations = [
'user' => ['userNickName' => 'nickName']
];
/**
* @param string $title
* @return void
*/
public function title(string $title): void
{
$this->whereLike('title', $title);
}
/**
* @param int|array $type
* @return void
*/
public function pushType(int|array $type): void
{
$this->whereIn('push_type', Arr::wrap($type));
}
/**
* @param array $pushBetween
* @return void
*/
public function pushBetween(array $pushBetween): void
{
$this->whereBetween('push_at', $pushBetween);
}
/**
* @param int $status
* @return void
*/
public function status(int $status): void
{
$currentTime = now()->toDateTimeString();
match ($status) {
0 => $this->where('begin_at', '>', $currentTime),
1 => $this->where('begin_at', '<=', $currentTime)->where('end_at', '>=', $currentTime),
2 => $this->where('end_at', '<', $currentTime)
};
}
}