<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;

/**
 * Class SerpUrl
 *
 * @property int $id
 * @property int $news_serp_result_id
 * @property int $category_id
 * @property string $category_name
 * @property string $source
 * @property string $url
 * @property string $country_iso
 * @property string|null $title
 * @property string|null $description
 * @property Carbon|null $serp_at
 * @property string $status
 * @property Carbon|null $created_at
 * @property Carbon|null $updated_at
 * @property NewsSerpResult $news_serp_result
 * @property Category $category
 */
class SerpUrl extends Model
{
    protected $table = 'serp_urls';

    protected $casts = [
        'news_serp_result_id' => 'int',
        'category_id' => 'int',
        'process_status' => 'int',
        'serp_at' => 'datetime',
        'picked' => 'boolean',
        'processed' => 'boolean',
        'crawled' => 'boolean',
        'written' => 'boolean',
        'url_posted_at' => 'datetime',
        'suggestion_data' => 'object',
    ];

    protected $fillable = [
        'news_serp_result_id',
        'category_id',
        'category_name',
        'source',
        'url',
        'country_iso',
        'title',
        'description',
        'process_status',
        'serp_at',
        'status',
        'picked',
        'processed',
        'crawled',
        'written',
        'url_posted_at',
        'suggestion_data',
    ];

    public function news_serp_result()
    {
        return $this->belongsTo(NewsSerpResult::class);
    }

    public function category()
    {
        return $this->belongsTo(Category::class);
    }
}
