Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function filterTourismPackage($params=''){
- //inner join all
- $collect = DB::table('tourism_package')->join('tenant_tourism_package', function( $join ) use ( $params ){
- $filter = $join->on('tourism_package.id','=','tenant_tourism_package.tourism_package_id');
- if( !empty($params['package']) ){
- $filter->whereIn('tenant_tourism_package.tourism_package_id',$params['package']);
- }
- })
- ->join('tourism_belt', function( $join ) use ( $params ) {
- $filter = $join->on('tourism_package.tourism_belt_id','=','tourism_belt.id');
- if( !empty($params['belt']) ){
- $filter->whereIn('tourism_belt.id',$params['belt']);
- }
- })
- //redudant
- ->join('ekraf_tenants as tenants', function( $join ){
- $join->on('tenant_tourism_package.ekraf_tenant_id','=','tenants.id');
- })
- ->join('tenant_categories', function( $join ){
- $filter = $join->on('tenants.id','=','tenant_categories.ekraf_tenant_id');
- if( !empty( $params['subsector'] ) ){
- $filter->whereIn('tenant_categories.category_id',$params['subsector']);
- }
- })
- ->join('tenant_address', function( $join ) {
- $join->on('tenants.id','=','tenant_address.ekraf_tenant_id');
- })
- ->select('tenants.id','tourism_package.id as id_package','tenant_address.latitude','tenant_address.longitude')
- ->distinct('tenants.id');
- if( !empty( $params['keyword'] ) ){
- $collect = $collect->where('tenants.tenant_name','like','%'. $params['keyword'] .'%');
- }
- return $collect->get();
- }
Add Comment
Please, Sign In to add comment