diff --git a/app/Http/Controllers/MenuItems.php b/app/Http/Controllers/MenuItems.php new file mode 100644 index 0000000..a0fc2fa --- /dev/null +++ b/app/Http/Controllers/MenuItems.php @@ -0,0 +1,10 @@ +resetInput(); + } + + public function resetForm(){ + $this->resetErrorBag(); + } + + protected $messages = [ + 'menuLevel.name.required' => 'Menu name is required.', + 'menuLevel.name.min' => 'Menu must be at-least 4 letters long.', + 'menuLevel.name.unique' => ':attribute menu already exists!.', + ]; + + protected function rules() + { + return [ + 'menuLevel.name' => 'required|min:4|unique:menu_levels,name' + ]; + } + + protected function validationAttributes() + { + return [ + 'menuLevel.name' => $this->menuLevel['name'], + ]; + } + + public function resetInput(){ + $this->menuLevel=['name'=>'']; + } + + + + public function submit(){ + $this->validate(); + $level=new MenuLevel(); + $level->name=$this->menuLevel['name']; + $level->save(); + $this->resetForm(); + $this->resetInput(); + $this->dispatchBrowserEvent('FirstModel',['show'=>false]); + } + + public function render() + { + return view('livewire.admin.menu.level'); + } +} diff --git a/app/Models/MenuItems.php b/app/Models/MenuItems.php new file mode 100644 index 0000000..8be2d88 --- /dev/null +++ b/app/Models/MenuItems.php @@ -0,0 +1,11 @@ +id(); + $table->timestamps(); + $table->string('name'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('menu_levels'); + } +}; diff --git a/database/migrations/2022_11_10_105400_create_menu_items_table.php b/database/migrations/2022_11_10_105400_create_menu_items_table.php new file mode 100644 index 0000000..44f8299 --- /dev/null +++ b/database/migrations/2022_11_10_105400_create_menu_items_table.php @@ -0,0 +1,41 @@ +id(); + $table->unsignedBigInteger('menu_id'); + $table->unsignedBigInteger('menu_level_id'); + $table->string('name'); + $table->timestamps(); + + //FOREIGN KEYS + $table->foreign('menu_id','menu_items_fk0')->on('menus')->references('id')->onUpdate('cascade')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + + public function down() + { + Schema::table('menu_items', function (Blueprint $table) { + $table->dropForeign('menu_links_fk0'); + }); + Schema::dropIfExists('menu_items'); + } +}; diff --git a/package-lock.json b/package-lock.json index 427c8f3..d6dd618 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "tailwind-scrollbar": "^2.1.0-preview.0" }, "devDependencies": { - "@tailwindcss/forms": "^0.5.2", + "@tailwindcss/forms": "^0.5.3", "@tailwindcss/typography": "^0.5.0", "alpinejs": "^3.10.4", "autoprefixer": "^10.4.13", diff --git a/package.json b/package.json index 955864f..452170e 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "build": "vite build" }, "devDependencies": { - "@tailwindcss/forms": "^0.5.2", + "@tailwindcss/forms": "^0.5.3", "@tailwindcss/typography": "^0.5.0", "alpinejs": "^3.10.4", "autoprefixer": "^10.4.13", diff --git a/resources/js/components/main.js b/resources/js/components/main.js index e976e43..6f4e778 100644 --- a/resources/js/components/main.js +++ b/resources/js/components/main.js @@ -5,18 +5,28 @@ // // }); -export function Main(data){ - return{ - darkMode:data.darkMode, - isSidebarOpen:false, - isFirstModelButtonClicked:false, - init() { - this.darkMode=true; - Alpine.effect(() => { - console.log( this.isModelButtonClicked); - }); - } - } +export function Main(data) { + return { + darkMode: data.darkMode, + isSidebarOpen: false, + isFirstModelButtonClicked: false, + + init() { + this.darkMode = true; + this.eventToListen(); + Alpine.effect(() => { + console.log(this.isFirstModelButtonClicked); + }); + }, + eventToListen() { + console.log('hello'); + window.addEventListener('FirstModel', event => { + if (event.detail.show === false) { + this.isFirstModelButtonClicked = false + } + }); + } + } } export default Main diff --git a/resources/views/components/item/button.blade.php b/resources/views/components/item/button.blade.php index ac254e5..0364d59 100644 --- a/resources/views/components/item/button.blade.php +++ b/resources/views/components/item/button.blade.php @@ -1,24 +1,44 @@ -@props(['size'=>'default']) +@props([ +'size'=>'medium', +'type'=>'button', +'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 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 ' +]) @switch($size) @case('small') - + @if($type==='submit') + + @else + + @endif @break - @case('default') - + @case('medium') + @if($type==='submit') + + @else + + @endif @break @case('large') - + @if($type==='submit') + + @else + + @endif @break @endswitch diff --git a/resources/views/components/item/elements/input.blade.php b/resources/views/components/item/elements/input.blade.php new file mode 100644 index 0000000..5dbabb5 --- /dev/null +++ b/resources/views/components/item/elements/input.blade.php @@ -0,0 +1,40 @@ +@props([ +'wireName', +'updating'=>'defer', +'debounce'=>'500ms', +'size'=>'small', +'label', +'name', +'placeholder', +]) + +