<?php

namespace DMZ\Models;

use Illuminate\Database\Eloquent\Model;

class Files extends Model

{
  protected $table ='files';
  public $fillable = [
      'id',
      'file',
      'created_at',
      'updated_at',
      'status',
      'name',
      'description',
      'hits',
      'created_by',
      'updated_by',
      'content_id',
      'extension',
      'type'
  ];
  public $timestamps = true;

  public function scopeGetFiles($query, $content_id)
    {
        return $query->select('files.*')
                     ->where('files.status',1)
                     ->where('files.type','file')
                     ->where('files.content_id',$content_id)
                     ->orderBy('created_at', 'desc');
    }
    public function scopeGetImages($query, $content_id)
      {
          return $query->select('files.*')
                       ->where('files.status',1)
                       ->where('files.type','image')
                       ->where('files.content_id',$content_id)
                       ->orderBy('created_at', 'desc');
       }
}
