diff --git a/app/Livewire/Filament/Color.php b/app/Livewire/Filament/Color.php index 92d1086..db1b777 100644 --- a/app/Livewire/Filament/Color.php +++ b/app/Livewire/Filament/Color.php @@ -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) ]); } } diff --git a/app/Livewire/Filament/Type.php b/app/Livewire/Filament/Type.php index 382f03c..e23e471 100644 --- a/app/Livewire/Filament/Type.php +++ b/app/Livewire/Filament/Type.php @@ -4,12 +4,110 @@ namespace App\Livewire\Filament; use Livewire\Component; use Livewire\Attributes\title; +use Livewire\WithPagination; +use Livewire\Attributes\Validate; +use Illuminate\Support\Facades\Auth; +use App\Models\FilamentType; +use Flux\Flux; #[title('Types')] class Type extends Component { + use WithPagination; + + // Validation + #[Validate('required')] + public $name = ''; + + public $description = ''; + + public $search =''; + + public $editid = ''; + public $deleteid = ''; + + + public function create() { + @Auth::check(); + + + // Validate + $this->validate(); + + $type = new FilamentType(); + $type->name = $this->name; + $type->description = $this->description; + $type->save(); + + // Clear the form + $this->resetInputFields(); + + // Close the modal + Flux::modal('createModal')->close(); + } + + public function edit($typeid) { + @Auth::check(); + + $editid = $typeid; + $this->editid = $editid; + + $type =FilamentType::findOrFail($editid); + + $this->name = $type->name; + $this->description = $type->description; + + Flux::modal('editModal')->show(); + } + + public function save($editid) { + @Auth::check(); + + $type = FilamentType::findOrFail($editid); + $type->name = $this->name; + $type->description = $this->description; + $type->save(); + + $this->resetInputFields(); + + Flux::modal('editModal')->close(); + } + public function deleteModal($typeid) { + @Auth::check(); + + $deleteid = $typeid; + $this->deleteid = $deleteid; + + $type = FilamentType::findOrFail($deleteid); + $this->name = $type->name; + $this->description = $type->description; + + Flux::modal('deleteModal')->show(); + } + public function delete($deleteid) { + @Auth::check(); + + $type = FilamentType::findOrFail($deleteid)->delete(); + + $this->deleteid = $deleteid; + Flux::modal('deleteModal')->close(); + + // Clear the form + $this->resetInputFields(); + } + + public function cancel() { + $this->resetInputFields(); + Flux::modals()->close(); + } + + public function resetInputFields() { + $this->reset(['name', 'description', 'deleteid', 'editid']); + } public function render() { - return view('livewire.filament.type'); + return view('livewire.filament.type', [ + 'types' => FilamentType::search('name', $this->search)->paginate(10) + ]); } } diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index 46bbd1f..19e6ff9 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -7,6 +7,7 @@ Dashboard + Orders Manufacturers diff --git a/resources/views/components/table.blade.php b/resources/views/components/table.blade.php index f89600b..f9f1f2e 100644 --- a/resources/views/components/table.blade.php +++ b/resources/views/components/table.blade.php @@ -1,17 +1,17 @@ -
+
- + {{ $tableheader }} - + {{ $slot }}
@isset($pagination) -
+
{{ $pagination }}
@endisset diff --git a/resources/views/components/table/header.blade.php b/resources/views/components/table/header.blade.php index ec6d27b..cb4dcd9 100644 --- a/resources/views/components/table/header.blade.php +++ b/resources/views/components/table/header.blade.php @@ -1,3 +1,3 @@ -merge(['class' => 'py-4 px-3 first:pl-6 last:pr-6']) }}> +merge(['class' => 'py-4 px-3 first:pl-6 last:pr-6 text-nuke-400']) }}> {{ $slot }} \ No newline at end of file diff --git a/resources/views/livewire/filament/color.blade.php b/resources/views/livewire/filament/color.blade.php index 8e8983b..c9cf640 100644 --- a/resources/views/livewire/filament/color.blade.php +++ b/resources/views/livewire/filament/color.blade.php @@ -7,7 +7,9 @@ - + + Create Color + @@ -25,16 +27,15 @@ @foreach ($colors as $color) - +

{{ $color->name }}

{{ $color->hex }}

- - - + Edit + Delete
@@ -48,51 +49,65 @@
- - -
-
- -
-
-

New Color

-
-
-
-
- - - + + +
+
+ Create color + Create a new color. +
+ + +
+ + Cancel + Create
-
- - -
- + + - - -
-
- + @empty($color) + @else + +
+
+
+ Edit color + Edit an existing color.
-
-

Edit Color

-
-
- -
- - - -
- -
- - + + +
+ + Cancel + Save +
- + +
+ @endempty + + +
+
+
+ Delete color? + +

You're about to delete this color.

+

This action cannot be reversed.

+
+
+ + +
+ + Cancel + Delete color +
+
+
+
\ No newline at end of file diff --git a/resources/views/livewire/filament/type.blade.php b/resources/views/livewire/filament/type.blade.php index cdda2ce..1be3886 100644 --- a/resources/views/livewire/filament/type.blade.php +++ b/resources/views/livewire/filament/type.blade.php @@ -1,3 +1,111 @@ -
- {{-- In work, do what you enjoy. --}} -
+
+ + {{ __('Types') }} + + + + + + + + Create Type + + + + + + +
+ + + Name + Description + Rolls + + + + @foreach ($types as $type) + +

{{ $type->name }}

+

{{ $type->description }}

+

+ +
+ Edit + Delete +
+
+ + @endforeach + + + {{ $types->links() }} + +
+ +
+ + + +
+
+
+ Create type + Create a new type. +
+ + +
+ + Cancel + Create +
+
+
+
+ + + @empty($type) + @else + +
+
+
+ Edit type + Edit an existing type. +
+ + +
+ + Cancel + Save +
+
+
+
+ @endempty + + + +
+
+
+ Delete type? + +

You're about to delete this type.

+

This action cannot be reversed.

+
+
+ + +
+ + Cancel + Delete type +
+
+
+
+ +
\ No newline at end of file diff --git a/resources/views/manufacturers/index.blade.php b/resources/views/manufacturers/index.blade.php index 74fa9af..8f46d22 100644 --- a/resources/views/manufacturers/index.blade.php +++ b/resources/views/manufacturers/index.blade.php @@ -28,7 +28,7 @@ @foreach ($manufacturers as $manufacturer) {{ $manufacturer->name }} - {{ $manufacturer->filament_count }} + {{ $manufacturer->filament_count }} {{ $manufacturer->website }} @isset($manufacturer->website) @endisset