48 lines
959 B
PHP
48 lines
959 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class PageView extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'website_id',
|
|
'visitor_id',
|
|
'analytics_session_id',
|
|
'url',
|
|
'path',
|
|
'title',
|
|
'referrer',
|
|
'time_on_page',
|
|
'viewed_at',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'viewed_at' => 'datetime',
|
|
'time_on_page' => 'integer',
|
|
];
|
|
}
|
|
|
|
public function website(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Website::class);
|
|
}
|
|
|
|
public function visitor(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Visitor::class);
|
|
}
|
|
|
|
public function session(): BelongsTo
|
|
{
|
|
return $this->belongsTo(AnalyticsSession::class, 'analytics_session_id');
|
|
}
|
|
}
|