<?php

namespace App\Models;

use App\Traits\HasImageUrl;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Blog extends Model
{
    use HasFactory;
    use HasImageUrl;
    protected $hidden = [
        'created_at',
        'updated_at',
        'pivot',
    ];
    protected $fillable = [
        'title',
        'category_id',
        'author_name',
        'description_for_blog_page',
        'author_icon',
        'blog_date_uploaded',
        'blog_label',
        'blog_image',
        'description',
        'quote',
        'quote_author_name',
        'quote_author_title',
        'first_description',
        'sescond_description',
        'description_third_part',
        'first_image',
        'second_image',
        'third_image',
        'bullet_points',
        'first_tag',
        'second_tag',
        'third_tag',
        'first_icon',
        'second_icon',
        'third_icon',
        'fourth_icon',
        'creator_job',
        'creator_name',
        'creator_about',
        'creator_image',
        'sentence',
        'meta_title',
        'meta_description',
        'meta_keyword',
        'gallery'
    ];

    protected $casts = [
        'bullet_points' => 'array',
        'gallery' => 'array',
    ];
    public function category()
    {
        return $this->belongsTo(BlogCategory::class, 'category_id');
    }
    public function tags()
    {
        return $this->belongsToMany(Tag::class, 'blog_tag', 'blog_id', 'tag_id');
    }
}
