<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * @property mixed id
 */
class Article extends Model
{
    //use soft delete
    use SoftDeletes;

    protected $fillable = [
        'image',
        'video',
        'video_type',
        'category_id',
        'user_id',
        'visit_counts'
    ];

    /**
     * Return descriptions for article
     * @return HasMany
     */
    public function descriptions() : HasMany
    {
        return $this->hasMany(ArticleDescription::class);
    }

    /**
     * Return category for article
     * @return BelongsTo
     */
    public function category() :BelongsTo
    {
        return $this->belongsTo(Category::class);
    }


    /**
     * Return other photos for article
     * @return HasMany
     */
    public function photos () :HasMany
    {
        return $this->hasMany(ArticlePhoto::class);
    }

}
