phase 6
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class DailyAggregate extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'website_id',
|
||||
'date',
|
||||
'visitors',
|
||||
'sessions',
|
||||
'page_views',
|
||||
'bounce_count',
|
||||
'total_duration',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'date' => 'date',
|
||||
'visitors' => 'integer',
|
||||
'sessions' => 'integer',
|
||||
'page_views' => 'integer',
|
||||
'bounce_count' => 'integer',
|
||||
'total_duration' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function website(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Website::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class PageDailyAggregate extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'website_id',
|
||||
'date',
|
||||
'path',
|
||||
'views',
|
||||
'unique_views',
|
||||
'total_time_on_page',
|
||||
'bounces',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'date' => 'date',
|
||||
'views' => 'integer',
|
||||
'unique_views' => 'integer',
|
||||
'total_time_on_page' => 'integer',
|
||||
'bounces' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function website(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Website::class);
|
||||
}
|
||||
}
|
||||
@@ -73,6 +73,21 @@ class Website extends Model
|
||||
return $this->hasMany(GoalConversion::class);
|
||||
}
|
||||
|
||||
public function dailyAggregates(): HasMany
|
||||
{
|
||||
return $this->hasMany(DailyAggregate::class);
|
||||
}
|
||||
|
||||
public function pageDailyAggregates(): HasMany
|
||||
{
|
||||
return $this->hasMany(PageDailyAggregate::class);
|
||||
}
|
||||
|
||||
public function getDataRetentionDaysAttribute(): int
|
||||
{
|
||||
return $this->settings['data_retention_days'] ?? 365;
|
||||
}
|
||||
|
||||
public function embedSnippet(): string
|
||||
{
|
||||
$scriptUrl = route('tracking.script', $this->tracking_id);
|
||||
|
||||
Reference in New Issue
Block a user