50 lines
1010 B
PHP
50 lines
1010 B
PHP
<?php
|
|||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
|
|
||
|
|
class Event extends Model
|
||
|
|
{
|
||
|
|
use HasFactory;
|
||
|
|
|
||
|
|
protected $fillable = [
|
||
|
|
'website_id',
|
||
|
|
'visitor_id',
|
||
|
|
'analytics_session_id',
|
||
|
|
'name',
|
||
|
|
'category',
|
||
|
|
'action',
|
||
|
|
'label',
|
||
|
|
'value',
|
||
|
|
'properties',
|
||
|
|
'occurred_at',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected function casts(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'value' => 'decimal:4',
|
||
|
|
'properties' => 'array',
|
||
|
|
'occurred_at' => 'datetime',
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
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');
|
||
|
|
}
|
||
|
|
}
|