GrafiteInc/CMS

View on GitHub
src/Models/File.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace Grafite\Cms\Models;

use Grafite\Cms\Models\CmsModel;

class File extends CmsModel
{
    public $table = 'files';

    public $primaryKey = 'id';

    protected $guarded = [];

    public static $rules = [
        'location' => 'required',
    ];

    protected $fillable = [
        'name',
        'location',
        'user',
        'tags',
        'details',
        'mime',
        'size',
        'is_published',
        'order',
    ];

    public function __construct(array $attributes = [])
    {
        $keys = array_keys(request()->except('_method', '_token'));
        $this->fillable(array_values(array_unique(array_merge($this->fillable, $keys))));
        parent::__construct($attributes);
    }
}