summaryrefslogtreecommitdiff
path: root/app/Models/Traits/AutoFillable.php
blob: 3ef85c9be5ec0cba97b67e638c8911314bf20f2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php

namespace App\Models\Traits;

use Illuminate\Support\Facades\Schema;

trait AutoFillable
{
    public function initializeAutoFillable()
    {
        $table = $this->getTable();
        $columns = Schema::getColumnListing($table);
        
        $protected = ['id', 'created_at', 'updated_at', 'deleted_at'];
        $this->fillable = array_diff($columns, $protected);
    }
}