/** * Get the relation constraint closure. * * @param string $method * @param \Sofa\Eloquence\ArgumentBag $args * @return \Closure */ protected function getMetaWhereConstraint($method, ArgumentBag $args) { $column = $args->get('column'); $args->set('column', 'meta_value'); if ($method === 'whereBetween') { return $this->getMetaBetweenConstraint($column, $args->get('values')); } return function ($query) use($column, $method, $args) { $query->where('meta_key', $column); if ($args->get('value') || $args->get('values')) { call_user_func_array([$query, $method], $args->all()); } }; }
/** * Determine whether where is a whereNull by the arguments passed to where method. * * @param \Sofa\Eloquence\ArgumentBag $args * @return boolean */ protected function isWhereNullByArgs(ArgumentBag $args) { return is_null($args->get('operator')) || is_null($args->get('value')) && !in_array($args->get('operator'), ['<>', '!=']); }
/** * Determine the operator for count relation query and set 'not' appropriately. * * @param string $method * @param \Sofa\Hookable\Contracts\ArgumentBag $args * @return string */ protected function getMappedOperator($method, ArgumentBag $args) { if ($not = $args->get('not')) { $args->set('not', false); } if ($null = $this->isWhereNull($method, $args)) { $args->set('not', true); } return $not ^ $null ? '<' : '>='; }