app/Repositories/Criteria/WithBalanceCriteria.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('balances', function ($query) {
			$query->where('balances.user_id', $this->user->id);
			$query->whereRaw('balances.valuta_id=valuta.id');
		})->addSelect(['balances.*', \DB::raw('COALESCE(balances.quantity, 0) as quantity')]);
	}
public function apply ( $ model , RepositoryInterface $ repository ) { return $ model -> leftJoin ( 'balances' , function ( $ query ) { $ query -> where ( 'balances.user_id' , $ this -> user -> id ) ; $ query -> whereRaw ( 'balances.valuta_id=valuta.id' ) ; } ) -> addSelect ( [ 'balances.*' , \ DB :: raw ( 'COALESCE(balances.quantity, 0) as quantity' ) ] ) ; }
Apply criteria in query repository
 @param                     $model
 @param RepositoryInterface $repository
Apply criteria in query repository @param $model @param RepositoryInterface $repository