Closed julianjedi closed 3 years ago
This feature allow us to easily create an autofill method for our models, just like in Laravel $model->fill($request->all());
$model->fill($request->all());
namespace Source\Models; use CoffeeCode\DataLayer\DataLayer; class Model extends DataLayer ... public function fill(array $data) : void { if($this->timestamps){ $this->guarded = ['created_at', 'updated_at']; } $this->columns = array_diff($this->columns, $this->guarded) ?? []; foreach ($this->columns as $col) { if(isset($data[$col]) && !empty($data[$col])) { $this->$col = $data[$col] ?? ""; } } }
This feature allow us to easily create an autofill method for our models, just like in Laravel
$model->fill($request->all());