10 || (int) $value > 2147483647 ) { throw new \InvalidArgumentException( 'staff_filter' ); } return (int) $value; } public static function request( $value ) { try { return self::normalize( $value ); } catch ( \InvalidArgumentException $error ) { return 0; } } public static function where( $value, string $column = 'a.staff_id' ): string { if ( ! in_array( $column, array( 'a.staff_id', 'g.staff_id', 'staff_id', 'appointments.staff_id', 'work.staff_id' ), true ) ) { throw new \InvalidArgumentException( 'staff_filter_column' ); } $value = self::normalize( $value ); return $value === 'unassigned' ? ' AND ' . $column . '=0' : ( $value > 0 ? ' AND ' . $column . '=' . (int) $value : '' ); } /** Placeholder value for `( %d = 0 OR = GREATEST( %d, 0 ) )`: 0 all, -1 unassigned (staff 0), n staff n. */ public static function arg( $value ): int { $value = self::normalize( $value ); return $value === 'unassigned' ? -1 : $value; } public static function enabled(): bool { return (bool) apply_filters( 'abientot_admin_staff_filters_enabled', false ) || ( new \Abientot\Repositories\ResourceBookingRepository() )->has_unassigned(); } public static function label(): string { return __( 'No staff assigned', 'abientot' ); } }