♻️ Move validation to Input class

This commit is contained in:
Dan Jones 2022-03-25 17:02:09 -05:00
commit 3246004e58
5 changed files with 79 additions and 37 deletions

25
app/Models/Model.php Normal file
View file

@ -0,0 +1,25 @@
<?php
namespace App\Models;
use Illuminate\Support\Str;
abstract class Model
{
public function __construct(array $data = [])
{
foreach ($data as $k => $v) {
$this->__set($k, $v);
}
}
public function __set(string $key, $value)
{
$setter = 'set' . Str::studly($key);
if (method_exists($this, $setter)) {
$this->$setter($value);
} elseif (property_exists($this, $key)) {
$this->$key = $value;
}
}
}