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); } }