fixed Color & Type View and Tables
This commit is contained in:
@@ -7,6 +7,7 @@ use Livewire\Attributes\Validate;
|
||||
use Livewire\Component;
|
||||
use Livewire\Attributes\title;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Flux\Flux;
|
||||
|
||||
use App\Models\Color as ColorModel;
|
||||
|
||||
@@ -22,13 +23,13 @@ class Color extends Component
|
||||
#[Validate('required')]
|
||||
public $hex = '';
|
||||
|
||||
public $createModal = false;
|
||||
|
||||
public $search ='';
|
||||
|
||||
// Edit Modal + Query
|
||||
public $editModal = false;
|
||||
public $editquery = '';
|
||||
|
||||
public $editid = '';
|
||||
public $deleteid = '';
|
||||
|
||||
|
||||
public function create() {
|
||||
@@ -49,39 +50,70 @@ class Color extends Component
|
||||
$this->reset(['name', 'hex']);
|
||||
|
||||
// Close the modal
|
||||
$this->createModal = false;
|
||||
Flux::modal('createModal')->close();
|
||||
}
|
||||
|
||||
public function edit($colorid) {
|
||||
@Auth::check();
|
||||
|
||||
$color =ColorModel::findOrFail($colorid);
|
||||
$editid = $colorid;
|
||||
$this->editid = $editid;
|
||||
|
||||
$color =ColorModel::findOrFail($editid);
|
||||
|
||||
$this->name = $color->name;
|
||||
$this->hex = $color->hex;
|
||||
|
||||
Flux::modal('editModal')->show();
|
||||
}
|
||||
|
||||
public function save($colorid) {
|
||||
public function save($editid) {
|
||||
@Auth::check();
|
||||
|
||||
$color = ColorModel::findOrFail($colorid);
|
||||
$color = ColorModel::findOrFail($editid);
|
||||
$color->name = $this->name;
|
||||
$color->hex = $this->hex;
|
||||
$color->save();
|
||||
|
||||
session()->flash('status', 'Color successfully updated.');
|
||||
|
||||
$this->editModal = false;
|
||||
Flux::modal('editModal')->close();
|
||||
}
|
||||
public function delete(ColorModel $color) {
|
||||
|
||||
public function deleteModal($colorid) {
|
||||
@Auth::check();
|
||||
$color->delete();
|
||||
|
||||
$deleteid = $colorid;
|
||||
$this->deleteid = $deleteid;
|
||||
|
||||
$color = ColorModel::findOrFail($colorid);
|
||||
$this->name = $color->name;
|
||||
$this->hex = $color->hex;
|
||||
|
||||
Flux::modal('deleteModal')->show();
|
||||
}
|
||||
public function delete($deleteid) {
|
||||
@Auth::check();
|
||||
|
||||
$color = ColorModel::findOrFail($deleteid)->delete();
|
||||
|
||||
$this->deleteid = $deleteid;
|
||||
Flux::modal('deleteModal')->close();
|
||||
|
||||
// Clear the form
|
||||
$this->reset(['name', 'hex', 'deleteid']);
|
||||
|
||||
session()->flash('status', 'Color successfully deleted.');
|
||||
}
|
||||
|
||||
public function cancel() {
|
||||
$this->reset(['name', 'hex', 'deleteid']);
|
||||
Flux::modals()->close();
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.filament.color', [
|
||||
'colors' => ColorModel::search('name', $this->search)->paginate(10)
|
||||
'colors' => ColorModel::search('name', $this->search)->paginate(20)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user