Create variable
private $data = [];
Function query data
$res = MyModel::where(function($q){
$s = $this->data;
if($s['ProvinceId']){
$q->where('ProvinceId',$s['ProvinceId']);
}
if($s['DistrictId']){
$q->where('DistrictId',$s['DistrictId']);
}
if($s['Name']){
$q->where('Name', 'like', '%'.$s['Name'].'%');
}
})->get();