<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class TargetCampaign extends Model
{
    protected $fillable = [
        'title','project_type','is_active',
        'required_count','referral_level',
        'start_at','end_at',
        'bonus_amount','bonus_wallet','description',
    ];

    protected $casts = [
        'is_active' => 'boolean',
        'start_at'  => 'datetime',
        'end_at'    => 'datetime',
        'bonus_amount' => 'decimal:2',
    ];

    public function scopeLive($q)
    {
        return $q->where('is_active', 1)
                 ->where('start_at', '<=', now())
                 ->where('end_at', '>=', now());
    }
}