saidy / voyager-dependent-dropdown
Create a Dependent dropdown fields to Voyager plugin
Installs: 43
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Language:Blade
pkg:composer/saidy/voyager-dependent-dropdown
Requires
- tcg/voyager: ^1.6
This package is auto-updated.
Last update: 2025-10-16 16:46:22 UTC
README
Voyager Dependent Dropdown Option with the help of git link https://github.com/d3turnes/dependent-dropdown-with-voyager
Install
To install run the following command
composer require saidy/voyager-dependent-dropdown php artisan vendor:publish --provider="Saidy\VoyagerDependentDropdown\Providers\VoyagerDependentServiceProvider"
Sample RelationShip method
<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class TraineeInfo extends Model { use HasFactory; public $timestamps = false; protected $primaryKey = 'trainee_id'; protected $table = 'trainee_info'; public $additional_attributes = ['trainee_full_name']; public function getTraineeFullNameAttribute() { return "{$this->trainee_name}: ({$this->trainee_id})"; } public static function postingUpazilaRelationship($id) { /** * * return [ * 'posting_upazila' => xxx, * 'division_id' => yyy, * 'district_id' => yyy * ] * */ return self::where('trainee_info.trainee_id', '=', $id) ->select( 'trainee_info.posting_upazila', 'division.division_id', 'division.division_id as posting_division', 'district.district_id', 'district.district_id as posting_district' ) ->join('upazila', 'upazila.upazila_id', '=', 'trainee_info.posting_upazila') ->join('district', 'upazila.district_id', '=', 'district.district_id') ->join('division', 'district.division_id', '=', 'division.division_id') ->first(); } }
Sample Config Option
{
"model": "App\\Models\\Division",
"name": "posting_division",
"route": "api.v1.dropdown",
"display": "Posting Division",
"placeholder": "Select Division",
"key": "division_id",
"label": "division_name",
"dependent_dropdown": [
{
"model": "App\\Models\\District",
"name": "posting_district",
"display": "Posting District",
"placeholder": "Select District",
"key": "district_id",
"label": "district_name",
"where": "division_id"
},
{
"model": "App\\Models\\Upazila",
"name": "posting_upazila",
"display": "Posting Upazila",
"placeholder": "Select Upazila",
"key": "upazila_id",
"label": "upazila_name",
"where": "district_id"
}
]
}