/** * Run a callback with constraints disabled on the relation. * * @param \Closure $callback * @return mixed */ public static function noConstraints(Closure $callback) { $previous = static::$constraints; static::$constraints = false; // When resetting the relation where clause, we want to shift the first element // off of the bindings, leaving only the constraints that the developers put // as "extra" on the relationships, and not original relation constraints. $results = call_user_func($callback); static::$constraints = $previous; return $results; }
/** * @param \Closure $callback * @return mixed */ public static function noConstraints(Closure $callback) { $previous = static::$constraints; static::$constraints = false; try { $results = call_user_func($callback); } finally { static::$constraints = $previous; } return $results; }
/** * Run a callback with constraints disabled on the relation. * * @param \Closure $callback * @return mixed */ public static function noConstraints(Closure $callback) { static::$constraints = false; // $results = call_user_func($callback); static::$constraints = true; return $results; }