<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Validator;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class CampaignList extends Model
{
    use HasFactory;

    protected $table = 'campaign_list';

    protected $fillable = [
        'campaign_name',
        'total_number',
        'transactionType',
        'user_id',
    ];
    protected $casts = [
        'created_at' => 'datetime:d-m-Y',
    ];
    public function validate($input = []){
        $validator = Validator::make($input,[
            'campaign_name' => 'required',
            'transactionType' => 'required',
            'total_number' => 'required',
        ]);

        return $validator;
    }

    public function number(){
        return $this->hasMany(Number::class, 'type_id', 'id')->where('type', 2);
    }
}
