@@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
@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.
thanks broo. its verry help full for me....🧡🧡🧡
Happy to help
Bro, i cant do this when i have two tables (manyToMany) with pivot table 😢
You can do it. Can you share screenshot or something for model and component class code so I can help you.
@@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
@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.