<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Spatie\Tags\HasTags;

/**
 * Class Meme
 *
 * @property int $id
 * @property string $type
 * @property int|null $category_id
 * @property int|null $user_id
 * @property int|null $meme_media_id
 * @property int|null $background_media_id
 * @property string $status
 * @property string $prompt
 * @property string|null $caption
 * @property string|null $meme_keywords
 * @property string|null $background
 * @property string $keywords
 * @property Carbon|null $created_at
 * @property Carbon|null $updated_at
 * @property string|null $deleted_at
 */
class Meme extends Model
{
    use HasTags, SoftDeletes;

    protected $table = 'memes';

    protected $casts = [

        'is_system' => 'boolean',

        'category_id' => 'int',
        'user_id' => 'int',
        'meme_media_id' => 'int',
        'background_media_id' => 'int',

        'meme_keywords' => 'array',
        'keywords' => 'array',

        'action_keywords' => 'array',
        'emotion_keywords' => 'array',
        'misc_keywords' => 'array',
    ];

    protected $fillable = [
        'type',
        'is_system',
        'category_id',
        'user_id',
        'meme_media_id',
        'background_media_id',
        'status',
        'prompt',
        'caption',
        'meme_keywords',
        'background',
        'keywords',
        'action_keywords',
        'emotion_keywords',
        'misc_keywords',
        'primary_keyword_type',
    ];

    public function meme_media()
    {
        return $this->hasOne(MemeMedia::class, 'id', 'meme_media_id');
    }

    public function background_media()
    {
        return $this->hasOne(BackgroundMedia::class, 'id', 'background_media_id');
    }
}
