<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ContestTranslation extends Model
{
    use \Cviebrock\EloquentSluggable\Sluggable;

    public $timestamps = false;

    protected $fillable = [
        'contest_id',
        'locale',
        'title',
        'slug',
        'tags',
        'description',
    ];

    public $casts = [
        'tags' => 'array',
    ];

    public function contest(): \Illuminate\Database\Eloquent\Relations\BelongsTo
    {
        return $this->belongsTo(Contest::class);
    }

    public function getRouteKeyName(): string
    {
        return 'slug';
    }

    /**
     * Return the sluggable configuration array for this model.
     */
    public function sluggable(): array
    {
        return [
            'slug' => [
                'source' => ['title', 'id'],
            ],
        ];
    }
}
