From 8e0aa5e90dd5cfb497254dcb05597ab6255d16da Mon Sep 17 00:00:00 2001 From: Amir Date: Mon, 14 Nov 2022 17:41:58 +0400 Subject: [PATCH] Adding Menu Levels --- app/Http/Livewire/Admin/Menu.php | 14 -- app/Http/Livewire/Admin/Menu/Level.php | 97 ++++++++---- .../Admin/Menu/MenuLevelDatatable.php | 116 ++++++++++++++ .../Livewire/Admin/Menu/MenuLevelTable.php | 72 --------- app/Http/Livewire/Admin/Menu/MenuParent.php | 146 ++++++++++++++++++ .../Admin/Menu/MenuParentDatatable.php | 116 ++++++++++++++ app/Http/Livewire/Layout/Footer.php | 13 ++ app/Traits/General.php | 17 +- app/View/Components/Layout/Main.php | 28 ++++ app/View/Components/Svg/Trash.php | 28 ++++ ...11_01_005851_create_menu_levels_table.php} | 0 .../2022_11_09_085026_create_menus_table.php | 7 + database/seeders/DatabaseSeeder.php | 3 +- database/seeders/MenuLevelSeeder.php | 21 +++ resources/js/app.js | 4 +- resources/js/components/main.js | 9 +- resources/js/components/wire.js | 13 ++ .../views/components/item/button.blade.php | 90 +++++++---- .../components/item/form-submit.blade.php | 4 +- .../views/components/item/modal.blade.php | 35 ++--- .../views/components/item/toast.blade.php | 8 +- .../views/components/layout/content.blade.php | 2 +- .../views/components/layout/main.blade.php | 9 ++ .../views/components/svg/trash.blade.php | 3 + resources/views/layouts/app.blade.php | 4 +- .../views/livewire/admin/dashboard.blade.php | 14 -- resources/views/livewire/admin/menu.blade.php | 23 --- .../views/livewire/admin/menu/level.blade.php | 34 ++-- .../livewire/admin/menu/menu-parent.blade.php | 35 +++++ .../views/livewire/layout/footer.blade.php | 6 + .../views/livewire/layout/header.blade.php | 2 +- .../components/table/th.blade.php | 2 +- .../components/table/tr.blade.php | 4 +- routes/admin.php | 2 +- tailwind.config.js | 1 + 35 files changed, 735 insertions(+), 247 deletions(-) delete mode 100644 app/Http/Livewire/Admin/Menu.php create mode 100644 app/Http/Livewire/Admin/Menu/MenuLevelDatatable.php delete mode 100644 app/Http/Livewire/Admin/Menu/MenuLevelTable.php create mode 100644 app/Http/Livewire/Admin/Menu/MenuParent.php create mode 100644 app/Http/Livewire/Admin/Menu/MenuParentDatatable.php create mode 100644 app/Http/Livewire/Layout/Footer.php create mode 100644 app/View/Components/Layout/Main.php create mode 100644 app/View/Components/Svg/Trash.php rename database/migrations/{2022_11_10_005851_create_menu_levels_table.php => 2022_11_01_005851_create_menu_levels_table.php} (100%) create mode 100644 database/seeders/MenuLevelSeeder.php create mode 100644 resources/js/components/wire.js create mode 100644 resources/views/components/layout/main.blade.php create mode 100644 resources/views/components/svg/trash.blade.php delete mode 100644 resources/views/livewire/admin/dashboard.blade.php delete mode 100644 resources/views/livewire/admin/menu.blade.php create mode 100644 resources/views/livewire/admin/menu/menu-parent.blade.php create mode 100644 resources/views/livewire/layout/footer.blade.php diff --git a/app/Http/Livewire/Admin/Menu.php b/app/Http/Livewire/Admin/Menu.php deleted file mode 100644 index 18c9b94..0000000 --- a/app/Http/Livewire/Admin/Menu.php +++ /dev/null @@ -1,14 +0,0 @@ -$this->pageHeader]); - } -} diff --git a/app/Http/Livewire/Admin/Menu/Level.php b/app/Http/Livewire/Admin/Menu/Level.php index a05e799..e7e526f 100644 --- a/app/Http/Livewire/Admin/Menu/Level.php +++ b/app/Http/Livewire/Admin/Menu/Level.php @@ -13,21 +13,24 @@ class Level extends Component public string $pageHeader = 'Menu Level'; public array $menuLevel; + public ?int $rowID = null; - public $editMenuRecord = null; + public $menuLevelRecord = null; + + protected $listeners = ['createMenuLevel', 'editMenuLevel', 'deleteMenuLevel']; - protected $listeners = ['editMenuLevel']; public function mount() { - $this->formInfo('create', 'Create', 'Create', 'Create Menu Levels'); - $this->formType = "create"; - $this->resetInput(); +// $this->modelInfo('create', 'Create', 'Create', 'Create Menu Levels'); +// $this->formType = "create"; + $this->resetForm(); } public function resetForm() { $this->resetErrorBag(); + $this->resetInput(); } protected $messages = [ @@ -39,7 +42,7 @@ public function resetForm() protected function rules() { return [ - 'menuLevel.name' => 'required|min:4|unique:menu_levels,name' + 'menuLevel.name' => 'required|min:4|unique:menu_levels,name,' . $this->rowID ]; } @@ -55,47 +58,85 @@ public function resetInput() $this->menuLevel = ['name' => '']; } + protected function getRecord($row) + { + $this->rowID = $row['id']; + $this->menuLevelRecord = MenuLevel::find($row)->first(); + } + + + public function createMenuLevel() + { + $this->resetForm(); + $this->modelInfo('create', 'Menu Level'); + $this->dispatchBrowserEvent('FirstModel', ['show' => true]); + } + public function editMenuLevel($row) { - $this->editMenuRecord = MenuLevel::find($row)->first(); - $this->menuLevel['name'] = $this->editMenuRecord->name; - $this->formInfo('update', 'Update', 'Update ' . $this->menuLevel['name'], 'Update ' . $this->menuLevel['name']); + $this->getRecord($row); + $this->modelInfo('update', $this->menuLevelRecord->name); + $this->menuLevel['name'] = $this->menuLevelRecord->name; + $this->dispatchBrowserEvent('FirstModel', ['show' => true]); + } + + public function deleteMenuLevel($row) + { + $this->getRecord($row); + $this->modelInfo('delete', $this->menuLevelRecord->name); + $this->menuLevel['name'] = $this->menuLevelRecord->name; $this->dispatchBrowserEvent('FirstModel', ['show' => true]); } + protected function afterSave($formType){ + $this->emit('refreshDatatable'); + $this->resetForm(); + $this->dispatchBrowserEvent('FirstModel', ['show' => false]); + + switch($formType){ + case 'create': + $this->dispatchBrowserEvent('Toast', ['show' => true, 'type' => 'success', 'message' => "'" . $this->menuLevelRecord->name . "'" . ' was added to Menu Level!']); + break; + + case 'update': + $this->dispatchBrowserEvent('Toast', ['show' => true, 'type' => 'success', 'message' => "'" . $this->menuLevelRecord->name . "'" . ' was updated!']); + break; + + case 'delete': + $this->dispatchBrowserEvent('Toast', ['show' => true, 'type' => 'success', 'message' => "'" . $this->menuLevelRecord->name . "'" . ' was deleted!']); + break; + } + } + public function submit() { - $this->validate(); + switch ($this->formType) { case 'create': - $level = new MenuLevel(); - $level->name = $this->menuLevel['name']; - $level->save(); - + $this->validate(); + $this->menuLevelRecord = new MenuLevel(); + $this->menuLevelRecord->name = $this->menuLevel['name']; + $this->menuLevelRecord->save(); + $this->afterSave($this->formType); break; case 'update': - $this->editMenuRecord->name = $this->menuLevel['name']; - $this->editMenuRecord->save(); + $this->validate(); + $this->menuLevelRecord->name = $this->menuLevel['name']; + $this->menuLevelRecord->save(); + $this->afterSave($this->formType); break; - } - if ($this->formType === 'create' || $this->formType === 'update') { - $this->emit('refreshDatatable'); - $this->resetForm(); - $this->resetInput(); - $this->dispatchBrowserEvent('FirstModel', ['show' => false]); - - if($this->formType === 'update'){ - $this->dispatchBrowserEvent('Toast', ['show' => true, 'type' => 'success', 'message' => "'" . $this->editMenuRecord->name . "'" . ' was updated!']); - }else{ - $this->dispatchBrowserEvent('Toast', ['show' => true, 'type' => 'success', 'message' => "'" . $level->name . "'" . ' was added to Menu Level!']); - } + case 'delete': + $this->menuLevelRecord->delete(); + $this->afterSave($this->formType); + break; } + } public function render() diff --git a/app/Http/Livewire/Admin/Menu/MenuLevelDatatable.php b/app/Http/Livewire/Admin/Menu/MenuLevelDatatable.php new file mode 100644 index 0000000..b62a326 --- /dev/null +++ b/app/Http/Livewire/Admin/Menu/MenuLevelDatatable.php @@ -0,0 +1,116 @@ + null, + ]; + + + public function configure(): void + { + $this->setPrimaryKey('id') + ->setPerPageAccepted([10, 25, 50, 100]) + ->setPerPage(10) + ->setSortingStatus(true) + ->setSortingPillsStatus(false) + ->setPageName('menu-levels') + ->setPaginationVisibilityStatus(true) + ->setPaginationStatus(true) + ->setDefaultSort('id', 'desc') + ->setQueryStringStatus(false) + ->setThAttributes(function (Column $column) { + if ($column->isField('id')) { + return [ + 'class' => '!w-[5%]', + ]; + } elseif ($column->isField('name')) { + return [ + 'class' => '!w-[60%]', + ]; + } elseif ($column->isField('created_at')) { + return [ + 'class' => '!w-[15%]', + ]; + } elseif ($column->isField('updated_at')) { + return [ + 'class' => '!w-[15%]', + ]; + } elseif ($column->getTitle() === 'Action') { + return [ + 'class' => '!w-[5%] text-center', + ]; + } + + return []; + }) + ->setThSortButtonAttributes(function (Column $column) { + if ($column->isField('created_at')) { + return [ + 'class' => 'mx-auto', + ]; + } elseif ($column->isField('updated_at')) { + return [ + 'class' => 'mx-auto', + ]; + } + + return []; + }) + ->setTdAttributes(function (Column $column, $row, $columnIndex, $rowIndex) { + if ($columnIndex === 2 || $columnIndex === 3) { + return [ + 'class' => 'text-center', + ]; + } + + return []; + }) + ->setUseHeaderAsFooterEnabled(); + } + + + public function columns(): array + { + return [ + Column::make("Id", "id") + ->searchable() + ->sortable(), + Column::make("Name", "name") + ->searchable() + ->sortable(), + Column::make("Created at", "created_at") + ->format(fn($value, $row, Column $column) => $row->created_at->diffForHumans()) + ->sortable(), + Column::make("Updated at", "updated_at") + ->format(fn($value, $row, Column $column) => $row->created_at->diffForHumans()) + ->sortable(), + + Column::make('Action', 'ID') + ->format( + fn($value, $row, Column $column) => '
+ + + + + +
+ ' + ) + ->html(), + + ]; + } +} diff --git a/app/Http/Livewire/Admin/Menu/MenuLevelTable.php b/app/Http/Livewire/Admin/Menu/MenuLevelTable.php deleted file mode 100644 index 823d470..0000000 --- a/app/Http/Livewire/Admin/Menu/MenuLevelTable.php +++ /dev/null @@ -1,72 +0,0 @@ - null, - ]; - - - - - public function configure(): void - { - $this->setPrimaryKey('id') - ->setPerPageAccepted([10, 25, 50, 100]) - ->setPerPage(10) - ->setSortingStatus(true) - ->setSortingPillsStatus(false) - ->setPageName('menu-levels') - ->setPaginationVisibilityStatus(true) - ->setPaginationStatus(true) - ->setDefaultSort('id', 'desc') - ->setQueryStringStatus(false) - -> setUseHeaderAsFooterEnabled(); - } - - - - - public function columns(): array - { - return [ - Column::make("Id", "id") - ->searchable(), - Column::make("Name", "name") - ->searchable() - ->sortable(), - Column::make("Created at", "created_at") - ->sortable(), - Column::make("Updated at", "updated_at") - ->sortable(), - Column::make('Edit') - ->label( - fn($row, Column $column) => 'Edit' - ), - LinkColumn::make('Action') - ->title(fn($row) => 'Edit') - ->location(fn($row) => route('admin.menu', $row)), - Column::make('Name') - ->format( - fn($value, $row, Column $column) => ' - - ' - ) - ->html(), - - ]; - } -} diff --git a/app/Http/Livewire/Admin/Menu/MenuParent.php b/app/Http/Livewire/Admin/Menu/MenuParent.php new file mode 100644 index 0000000..ef2a70a --- /dev/null +++ b/app/Http/Livewire/Admin/Menu/MenuParent.php @@ -0,0 +1,146 @@ +modelInfo('create', 'Create', 'Create', 'Create Menu Levels'); +// $this->formType = "create"; + $this->resetForm(); + } + + public function resetForm() + { + $this->resetErrorBag(); + $this->resetInput(); + } + + protected $messages = [ + 'menu.name.required' => 'Menu name is required.', + 'menu.name.min' => 'Menu must be at-least 4 letters long.', + 'menu.name.unique' => ':attribute menu already exists!.', + ]; + + protected function rules() + { + return [ + 'menu.name' => 'required|min:4|unique:menus,name,' . $this->rowID + ]; + } + + protected function validationAttributes() + { + return [ + 'menu.name' => $this->menu['name'], + ]; + } + + public function resetInput() + { + $this->menu = ['name' => '']; + } + + protected function getRecord($row) + { + $this->rowID = $row['id']; + $this->menuRecord = Menu::find($row)->first(); + } + + + public function createMenu() + { + $this->resetForm(); + $this->modelInfo('create', 'Menu'); + $this->dispatchBrowserEvent('FirstModel', ['show' => true]); + } + + public function editMenu($row) + { + $this->getRecord($row); + $this->modelInfo('update', $this->menuRecord->name); + $this->menu['name'] = $this->menuRecord->name; + $this->dispatchBrowserEvent('FirstModel', ['show' => true]); + } + + public function deleteMenu($row) + { + $this->getRecord($row); + $this->modelInfo('delete', $this->menuRecord->name); + $this->menu['name'] = $this->menuRecord->name; + $this->dispatchBrowserEvent('FirstModel', ['show' => true]); + } + + protected function afterSave($formType){ + $this->emit('refreshDatatable'); + $this->resetForm(); + $this->dispatchBrowserEvent('FirstModel', ['show' => false]); + + switch($formType){ + case 'create': + $this->dispatchBrowserEvent('Toast', ['show' => true, 'type' => 'success', 'message' => "'" . $this->menuRecord->name . "'" . ' was added to Menu Level!']); + break; + + case 'update': + $this->dispatchBrowserEvent('Toast', ['show' => true, 'type' => 'success', 'message' => "'" . $this->menuRecord->name . "'" . ' was updated!']); + break; + + case 'delete': + $this->dispatchBrowserEvent('Toast', ['show' => true, 'type' => 'success', 'message' => "'" . $this->menuRecord->name . "'" . ' was deleted!']); + break; + } + } + + + public function submit() + { + + + switch ($this->formType) { + + case 'create': + $this->validate(); + $this->menuRecord = new Menu(); + $this->menuRecord->name = $this->menu['name']; + $this->menuRecord->save(); + $this->afterSave($this->formType); + break; + + case 'update': + $this->validate(); + $this->menuRecord->name = $this->menu['name']; + $this->menuRecord->save(); + $this->afterSave($this->formType); + break; + + case 'delete': + $this->menuRecord->delete(); + $this->afterSave($this->formType); + break; + } + + + } + + public function render() + { + return view('livewire.admin.menu.menu-parent'); + } +} diff --git a/app/Http/Livewire/Admin/Menu/MenuParentDatatable.php b/app/Http/Livewire/Admin/Menu/MenuParentDatatable.php new file mode 100644 index 0000000..59e9be1 --- /dev/null +++ b/app/Http/Livewire/Admin/Menu/MenuParentDatatable.php @@ -0,0 +1,116 @@ + null, + ]; + + + public function configure(): void + { + $this->setPrimaryKey('id') + ->setPerPageAccepted([10, 25, 50, 100]) + ->setPerPage(10) + ->setSortingStatus(true) + ->setSortingPillsStatus(false) + ->setPageName('menu-levels') + ->setPaginationVisibilityStatus(true) + ->setPaginationStatus(true) + ->setDefaultSort('id', 'desc') + ->setQueryStringStatus(false) + ->setThAttributes(function (Column $column) { + if ($column->isField('id')) { + return [ + 'class' => '!w-[5%]', + ]; + } elseif ($column->isField('name')) { + return [ + 'class' => '!w-[60%]', + ]; + } elseif ($column->isField('created_at')) { + return [ + 'class' => '!w-[15%]', + ]; + } elseif ($column->isField('updated_at')) { + return [ + 'class' => '!w-[15%]', + ]; + } elseif ($column->getTitle() === 'Action') { + return [ + 'class' => '!w-[5%] text-center', + ]; + } + + return []; + }) + ->setThSortButtonAttributes(function (Column $column) { + if ($column->isField('created_at')) { + return [ + 'class' => 'mx-auto', + ]; + } elseif ($column->isField('updated_at')) { + return [ + 'class' => 'mx-auto', + ]; + } + + return []; + }) + ->setTdAttributes(function (Column $column, $row, $columnIndex, $rowIndex) { + if ($columnIndex === 2 || $columnIndex === 3) { + return [ + 'class' => 'text-center', + ]; + } + + return []; + }) + ->setUseHeaderAsFooterEnabled(); + } + + + public function columns(): array + { + return [ + Column::make("Id", "id") + ->searchable() + ->sortable(), + Column::make("Name", "name") + ->searchable() + ->sortable(), + Column::make("Created at", "created_at") + ->format(fn($value, $row, Column $column) => $row->created_at->diffForHumans()) + ->sortable(), + Column::make("Updated at", "updated_at") + ->format(fn($value, $row, Column $column) => $row->created_at->diffForHumans()) + ->sortable(), + + Column::make('Action', 'ID') + ->format( + fn($value, $row, Column $column) => '
+ + + + + +
+ ' + ) + ->html(), + + ]; + } +} diff --git a/app/Http/Livewire/Layout/Footer.php b/app/Http/Livewire/Layout/Footer.php new file mode 100644 index 0000000..8a8d0e4 --- /dev/null +++ b/app/Http/Livewire/Layout/Footer.php @@ -0,0 +1,13 @@ +formType = $formType; + ($submitName==='') ? $this->submitName = "let`s Create" : $this->submitName = $submitName; + ($modalHeader==='') ? $this->modalHeader = "New ".$name : $this->modalHeader = $modalHeader; + break; case 'update': $this->formType = $formType; - $this->buttonName = $buttonName; - $this->submitName = $submitName; - $this->modalHeader = $modalHeader; + ($submitName==='') ? $this->submitName = "Yes, Update" : $this->submitName = $submitName; + ($modalHeader==='') ? $this->modalHeader = "Update ".$name : $this->modalHeader = $modalHeader; + break; + case 'delete': + $this->formType = $formType; + ($submitName==='') ? $this->submitName = "Yes, Delete" : $this->submitName = $submitName; + ($modalHeader==='') ? $this->modalHeader = "Delete ".$name : $this->modalHeader = $modalHeader; break; } } diff --git a/app/View/Components/Layout/Main.php b/app/View/Components/Layout/Main.php new file mode 100644 index 0000000..152fbb1 --- /dev/null +++ b/app/View/Components/Layout/Main.php @@ -0,0 +1,28 @@ +id(); $table->string('name')->unique(); $table->string('svg')->unique()->nullable(); + $table->unsignedBigInteger('menu_levels_id'); $table->timestamps(); + + //FOREIGN KEYS + $table->foreign('menu_levels_id','menus_fk0')->on('menu_levels')->references('id')->onUpdate('cascade')->onDelete('cascade'); }); } @@ -28,6 +32,9 @@ public function up() */ public function down() { + Schema::table('menu_items', function (Blueprint $table) { + $table->dropForeign('menus_fk0'); + }); Schema::dropIfExists('menus'); } }; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 58a4f3a..7bde4f0 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -22,7 +22,8 @@ public function run() ]); \App\Models\User::factory(10)->create(); - \App\Models\Admin::factory()->create(); + + $this->call(MenuLevelSeeder::class); } } diff --git a/database/seeders/MenuLevelSeeder.php b/database/seeders/MenuLevelSeeder.php new file mode 100644 index 0000000..741c791 --- /dev/null +++ b/database/seeders/MenuLevelSeeder.php @@ -0,0 +1,21 @@ + 'Parent']); + MenuLevel::create([ 'name' => 'Child 1']); + MenuLevel::create([ 'name' => 'Child 2']); + } +} diff --git a/resources/js/app.js b/resources/js/app.js index d7f8819..90fe2d0 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -4,12 +4,14 @@ import('preline'); import Alpine from 'alpinejs'; import persist from '@alpinejs/persist' Alpine.plugin(persist) -import Main from './components/main'; +import {Main} from './components/main'; +import {Wire} from "./components/wire"; Alpine.data('Main', Main) +Alpine.data('Wire', Wire) window.Alpine = Alpine; diff --git a/resources/js/components/main.js b/resources/js/components/main.js index d58005e..bc20903 100644 --- a/resources/js/components/main.js +++ b/resources/js/components/main.js @@ -1,10 +1,3 @@ -// document.addEventListener('alpine:init', function () { -// Alpine.data('Main', ($wire, data) => ({ -// darkMode: data.darkMode -// })); -// -// }); - export function Main(data) { return { darkMode: data.darkMode, @@ -12,11 +5,11 @@ export function Main(data) { toast:{'show':false,'type':'normal','message':'Some message!'}, isFirstModelButtonClicked: false, + init() { this.darkMode = true; this.eventToListen(); Alpine.effect(() => { - console.log(this.isFirstModelButtonClicked); }); }, diff --git a/resources/js/components/wire.js b/resources/js/components/wire.js new file mode 100644 index 0000000..702ede6 --- /dev/null +++ b/resources/js/components/wire.js @@ -0,0 +1,13 @@ +export function Wire($wire, data) { + return { + formType: $wire.entangle('formType'), + init() { + Alpine.effect(() => { + }); + }, + } +} + +export default Wire + + diff --git a/resources/views/components/item/button.blade.php b/resources/views/components/item/button.blade.php index 56c226e..c78270f 100644 --- a/resources/views/components/item/button.blade.php +++ b/resources/views/components/item/button.blade.php @@ -1,46 +1,78 @@ @props([ 'size'=>'medium', 'type'=>'button', +'formType'=>'default', 'defaultBg'=>'transition-all duration-300 inline-flex justify-center items-center gap-2 rounded-md border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-white focus:ring-blue-600 transition-all text-sm dark:bg-oblue-100 dark:hover:bg-oblue-100 dark:border-olblue-800/[0.5] dark:text-gray-400 dark:hover:text-white dark:focus:ring-offset-oblue-100', -'primaryBg'=>'transition-all duration-300 inline-flex justify-center items-center gap-2 rounded-md border font-medium bg-blue-600 text-gray-100 shadow-sm align-middle hover:bg-blue-700 border-blue-700 dark:border-blue-400 hover:text-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-white focus:ring-blue-300 transition-all text-sm ' +'primaryBg'=>'transition-all duration-300 inline-flex justify-center items-center gap-2 rounded-md border font-medium bg-blue-600 text-gray-100 shadow-sm align-middle hover:bg-blue-700 border-blue-700 dark:border-blue-400 hover:text-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-white focus:ring-blue-300 transition-all text-sm dark:bg-blue-700 dark:hover:bg-blue-800 dark:border-blue-600/[0.5] dark:text-blue-200 dark:hover:text-white dark:focus:ring-offset-blue-100', +'successBg'=>'transition-all duration-300 inline-flex justify-center items-center gap-2 rounded-md border font-medium bg-green-600 text-gray-100 shadow-sm align-middle hover:bg-green-700 border-green-700 dark:border-green-400 hover:text-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-white focus:ring-green-300 transition-all text-sm dark:bg-green-700 dark:hover:bg-green-800 dark:border-green-600/[0.5] dark:text-green-200 dark:hover:text-white dark:focus:ring-offset-oblue-100', +'dangerBg'=>'transition-all duration-300 inline-flex justify-center items-center gap-2 rounded-md border font-medium bg-red-600 text-gray-100 shadow-sm align-middle hover:bg-red-700 border-red-700 dark:border-red-400 hover:text-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-white focus:ring-red-300 transition-all text-sm dark:bg-red-700 dark:hover:bg-red-800 dark:border-red-600/[0.5] dark:text-red-200 dark:hover:text-white dark:focus:ring-offset-red-100' ]) +
@switch($size) @case('small') - @if($type==='submit') - - @else - - @endif + + @if($formType==='create') + + @elseif($formType==='update') + + @elseif($formType==='delete') + + @else + + @endif + @break @case('medium') - @if($type==='submit') - - @else - - @endif + + @if($formType==='create') + + @elseif($formType==='update') + + @elseif($formType==='delete') + + @else + + @endif + @break @case('large') - @if($type==='submit') - - @else - - @endif + @if($formType==='create') + + @elseif($formType==='update') + + @elseif($formType==='delete') + + @else + + @endif @break @endswitch - +
diff --git a/resources/views/components/item/form-submit.blade.php b/resources/views/components/item/form-submit.blade.php index 47f1e59..5a00136 100644 --- a/resources/views/components/item/form-submit.blade.php +++ b/resources/views/components/item/form-submit.blade.php @@ -1,10 +1,10 @@ -@props(['name']) +@props(['formType'=>'none','name'])
Close - + {{$name}}
diff --git a/resources/views/components/item/modal.blade.php b/resources/views/components/item/modal.blade.php index 5d277b1..c68f75a 100644 --- a/resources/views/components/item/modal.blade.php +++ b/resources/views/components/item/modal.blade.php @@ -1,34 +1,17 @@ @props([ 'type', 'size'=>'small', -'buttonName'=>'Give some name', 'modalHeader'=>'Give a header', 'smallModal'=>'sm:max-w-lg sm:w-full ', 'mediumModal'=>'md:max-w-2xl md:w-full ', 'largeModal'=>'lg:max-w-4xl lg:w-full ', ]) - - @switch($type) - @case('create') - - @break - - @case('update') - - @break - @case('delete') - - @break - @endswitch - - {{__($buttonName)}} -
-
-
+

@switch($type) @case('create') - + @break @case('update') - + @break @case('delete') - + @break @endswitch @@ -72,8 +55,10 @@ class="max-h-full !min-w-full overflow-hidden flex flex-col bg-white border shad

- + Close diff --git a/resources/views/components/item/toast.blade.php b/resources/views/components/item/toast.blade.php index 32e188b..bd788cb 100644 --- a/resources/views/components/item/toast.blade.php +++ b/resources/views/components/item/toast.blade.php @@ -11,7 +11,7 @@ {{-- Normal Message --}}