<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class Banner
 *
 * @package App
 * @property string $image
 * @property string $link
 * @property string $header
 * @property string $sub_header
 * @property integer $priority
 * @property integer $time
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Banner newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Banner newQuery()
 * @method static \Illuminate\Database\Query\Builder|\App\Banner onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Banner query()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Query\Builder|\App\Banner withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\Banner withoutTrashed()
 * @mixin \Eloquent
 */
class Banner extends Model
{
    const PAGINATE = 20;

    use SoftDeletes;

    protected $fillable = ['image', 'priority', 'time', 'link', 'header', 'sub_header'];
    protected $hidden = ['created_at', 'updated_at', 'deleted_at', 'pivot'];

    /**
     * Set attribute to money format
     * @param $input
     */
    public function setPriorityAttribute($input)
    {
        $this->attributes['priority'] = $input ? $input : null;
    }

    /**
     * Set attribute to money format
     * @param $input
     */
    public function setTimeAttribute($input)
    {
        $this->attributes['time'] = $input ? $input : null;
    }
}
