<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class AdCampaignReport extends Model
{
    use HasFactory;

    protected $fillable = [
        'ad_campaign_id',
        'spend',
        'reach',
        'impressions',
        'clicks',
        'ctr',
        'cpc',
        'cpm',
        'results',
        'cost_per_result',
        'messages',
        'leads',
        'report_date',
        'raw_json',
    ];

    protected $casts = [
        'report_date' => 'date',
        'spend' => 'decimal:2',
        'ctr' => 'decimal:2',
        'cpc' => 'decimal:2',
        'cpm' => 'decimal:2',
        'cost_per_result' => 'decimal:2',
        'raw_json' => 'array',
    ];

    public function campaign()
    {
        return $this->belongsTo(AdCampaign::class, 'ad_campaign_id');
    }
}
