51 lines
1.0 KiB
PHP
51 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class TrackingContentSelection extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'device_id',
|
|
'user_agent',
|
|
'ip_address',
|
|
'platform',
|
|
'content_type',
|
|
'content_id',
|
|
'content_name',
|
|
'search_query',
|
|
'selection_method',
|
|
'action_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'action_at' => 'datetime',
|
|
'created_at' => 'datetime',
|
|
'updated_at' => 'datetime',
|
|
];
|
|
|
|
protected $attributes = [
|
|
'platform' => 'web',
|
|
];
|
|
|
|
/**
|
|
* Get the related content (polymorphic relationship)
|
|
*/
|
|
public function content()
|
|
{
|
|
if ($this->content_type === 'meme') {
|
|
return $this->belongsTo(MemeMedia::class, 'content_id');
|
|
}
|
|
|
|
if ($this->content_type === 'background') {
|
|
return $this->belongsTo(BackgroundMedia::class, 'content_id');
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|