Select2 Dropdown with Laravel Livewire 3 | EP 30

Поділитися
Вставка
  • Опубліковано 6 лют 2025
  • In this video, i will show how to add select2 dropdown box in laravel liveiwre 3.
    #laravel #livewire #select2 #dropdown #itsolutionstuff

КОМЕНТАРІ •

  • @buddikathilakarathna1446
    @buddikathilakarathna1446 14 днів тому +1

    thanks broo. its verry help full for me....🧡🧡🧡

  • @daghsny
    @daghsny 8 днів тому +1

    Bro, i cant do this when i have two tables (manyToMany) with pivot table 😢

    • @savanihd
      @savanihd  8 днів тому

      You can do it. Can you share screenshot or something for model and component class code so I can help you.

    • @daghsny
      @daghsny 8 днів тому +1

      @@savanihd i can,t post a link in youtube here :/
      Models relationships in your models:
      In your Level model:
      php
      public function fields()
      {
      return $this->belongsToMany(Field::class);
      }
      In your Field model:
      php
      public function levels()
      {
      return $this->belongsToMany(Level::class);
      }
      pivot table:
      php artisan make:migration create_field_level_table
      migration
      public function up()
      {
      Schema::create('field_level', function (Blueprint $table) {
      $table->id();
      $table->foreignId('field_id')->constrained()->onDelete('cascade');
      $table->foreignId('level_id')->constrained()->onDelete('cascade');
      $table->timestamps();
      });
      }
      Now i would like to create the components (class & view) with livewire to a Dependent Dropdown
      in which i can get the list of field for chosen level

    • @savanihd
      @savanihd  8 днів тому

      @daghsny You need to retrieve a list of fields from the database, similar to how I did for the Country model.
      Then, when you select a field, it should fetch the corresponding levels, just like I did for the states data.
      You can start with this first step.