<?php

namespace App\Models;

use App\Traits\ModelTrait;
use Illuminate\Database\Eloquent\Model;
use Laracasts\Presenter\PresentableTrait;

class NewsDescription extends Model
{
    use ModelTrait, PresentableTrait;

    protected $presenter = 'App\Presenters\ContentPresenter';

    protected $table   = 'news_descriptions';

    protected $guarded = [];

    protected $casts = [
        'imgs' => 'collection',
    ];

    public    $timestamps = false;

    public function getSummaryAttribute($value)
    {
        if (config('visit') == 'frontend') {
            return empty($value) ? str_limit(strip_tags($this->attributes['content']), 300) : $value;
        }

        return $value;
    }
}
