<?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 Cobon extends Model
{
    //use soft delete
    use SoftDeletes;

    protected $fillable = [
        'code',
        'discount_type',
        'discount_amount',
        'type',
        'start_date',
        'end_date'
    ];

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


    /**
     * Return category for article
     * @return BelongsToMany
     */
   public function items() 
    {
        return $this->belongsToMany(CobonItem::class,'cobon_items','cobon_id','item_id');
    }
}
