app/Repositories/Criteria/ValutaMarketCriteria.php
/**
     * Apply criteria in query repository
     *
     * @param                     $model
     * @param RepositoryInterface $repository
     *
     * @return mixed
     */
Apply criteria in query repository
@param                     $model
@param RepositoryInterface $repository

@return mixed
Apply criteria in query repository @param $model @param RepositoryInterface $repository @return mixed
public function apply($model, RepositoryInterface $repository)
    {
        return $model->leftJoin('valuta as vftr', function ($join) {
	        $join->where(function ($query) {
		        $query->whereColumn('valuta_pairs.valuta_primary_id', 'vftr.id');
		        $query->orWhere(function ($query) {
			        $query->whereColumn('valuta_pairs.valuta_secondary_id', 'vftr.id');
		        });
	        })->where(function ($query) {
		        $query->where('vftr.symbol', $this->valutae[0]);
		        $query->orWhere('vftr.symbol', $this->valutae[1]);
	        });
        })->addSelect('valuta_pairs.*')->groupBy('valuta_pairs.id')->havingRaw('COUNT(vftr.id) = 2');
    }
public function apply ( $ model , RepositoryInterface $ repository ) { return $ model -> leftJoin ( 'valuta as vftr' , function ( $ join ) { $ join -> where ( function ( $ query ) { $ query -> whereColumn ( 'valuta_pairs.valuta_primary_id' , 'vftr.id' ) ; $ query -> orWhere ( function ( $ query ) { $ query -> whereColumn ( 'valuta_pairs.valuta_secondary_id' , 'vftr.id' ) ; } ) ; } ) -> where ( function ( $ query ) { $ query -> where ( 'vftr.symbol' , $ this -> valutae [ 0 ] ) ; $ query -> orWhere ( 'vftr.symbol' , $ this -> valutae [ 1 ] ) ; } ) ; } ) -> addSelect ( 'valuta_pairs.*' ) -> groupBy ( 'valuta_pairs.id' ) -> havingRaw ( 'COUNT(vftr.id) = 2' ) ; }
Apply criteria in query repository
 @param                     $model
 @param RepositoryInterface $repository
Apply criteria in query repository @param $model @param RepositoryInterface $repository