TrafficTrends.php
2.0 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
55
56
57
58
59
60
61
62
63
64
<?php
namespace App\Models\Bside\Statistics;
use App\Models\Base;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\Bside\Statistics\TrafficTrends
*
* @property int $id
* @property string|null $day 统计当天日期
* @property int|null $pvnum 当天的访问次数PV
* @property int|null $ipnum 当天的独立访问IP数量
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @method static Builder|TrafficTrends newModelQuery()
* @method static Builder|TrafficTrends newQuery()
* @method static Builder|TrafficTrends query()
* @method static Builder|TrafficTrends whereCreatedAt($value)
* @method static Builder|TrafficTrends whereDay($value)
* @method static Builder|TrafficTrends whereId($value)
* @method static Builder|TrafficTrends whereIpnum($value)
* @method static Builder|TrafficTrends wherePvnum($value)
* @method static Builder|TrafficTrends whereUpdatedAt($value)
* @mixin \Eloquent
*/
class TrafficTrends extends Base
{
protected $table = 'gl_traffic_trends';
/**
* * 根据时间获取数据
* @param array|string $date
* @return TrafficTrends[]|Builder[]|Collection
*/
public function getDaysLists($date = null)
{
$query = $this->query();
if ($date != null) {
if (is_array($date)) {
$query->whereIn('day', $date);
} else {
$query->where('day', $date);
}
} else {
$query->whereYear('day', '=', date("Y"))
->whereMonth('day', '=', date("m"))
->whereDay('day', '=', date("d"));
}
return $query->get();
}
/**
* @param string|null $date
* @return TrafficTrends|Builder|Model|object|null
*/
public function getDay(string $date = null)
{
return $this->query()->where('day', $date ?? date('Y-m-d'))->first();
}
}