Update
This commit is contained in:
51
app/Models/TrackingContentSelection.php
Normal file
51
app/Models/TrackingContentSelection.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
91
app/Models/TrackingExport.php
Normal file
91
app/Models/TrackingExport.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class TrackingExport extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'device_id',
|
||||
'user_agent',
|
||||
'ip_address',
|
||||
'platform',
|
||||
'meme_id',
|
||||
'meme_media_id',
|
||||
'background_media_id',
|
||||
'caption_texts',
|
||||
'export_format',
|
||||
'export_quality',
|
||||
'export_status',
|
||||
'error_message',
|
||||
'action_at',
|
||||
'completed_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'caption_texts' => 'array',
|
||||
'action_at' => 'datetime',
|
||||
'completed_at' => 'datetime',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $attributes = [
|
||||
'platform' => 'web',
|
||||
'export_quality' => 'standard',
|
||||
'export_status' => 'initiated',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the associated meme
|
||||
*/
|
||||
public function meme(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Meme::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the associated meme media
|
||||
*/
|
||||
public function memeMedia(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(MemeMedia::class, 'meme_media_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the associated background media
|
||||
*/
|
||||
public function backgroundMedia(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(BackgroundMedia::class, 'background_media_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope for completed exports
|
||||
*/
|
||||
public function scopeCompleted($query)
|
||||
{
|
||||
return $query->where('export_status', 'completed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope for failed exports
|
||||
*/
|
||||
public function scopeFailed($query)
|
||||
{
|
||||
return $query->where('export_status', 'failed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope for processing exports
|
||||
*/
|
||||
public function scopeProcessing($query)
|
||||
{
|
||||
return $query->where('export_status', 'processing');
|
||||
}
|
||||
}
|
||||
33
app/Models/TrackingSearch.php
Normal file
33
app/Models/TrackingSearch.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class TrackingSearch extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'device_id',
|
||||
'user_agent',
|
||||
'ip_address',
|
||||
'platform',
|
||||
'search_type',
|
||||
'search_query',
|
||||
'search_filters',
|
||||
'action_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'search_filters' => 'array',
|
||||
'action_at' => 'datetime',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $attributes = [
|
||||
'platform' => 'web',
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user