saidy/voyager-dependent-dropdown
最新稳定版本:1.0.3
Composer 安装命令:
composer require saidy/voyager-dependent-dropdown
包简介
Create a Dependent dropdown fields to Voyager plugin
README 文档
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"
}
]
}
统计信息
- 总下载量: 45
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-04-28