fixed Database Error while creating new color

This commit is contained in:
2025-03-16 01:33:15 +01:00
parent 990630ab2e
commit 9b3913b68c
3 changed files with 46 additions and 19 deletions
+14 -4
View File
@@ -22,17 +22,27 @@ class Color extends Component
#[Validate('required')]
public $hex = '';
public $createModal = false;
public function create() {
@Auth::check();
// Validate
$this->validate();
// Create the color
ColorModel::create([
$this->all()
]);
$color = new ColorModel();
$color->name = $this->name;
$color->hex = $this->hex;
$color->save();
session()->flash('status', 'Color successfully created.');
// Clear the form
$this->reset(['name', 'hex']);
// Close the modal
$this->createModal = false;
}
public function delete(Color $color) {