Main Navigation

\Aksara\Laboratory\Core->havingIn()

The documentation and cheat sheet of our framework

havingIn() adds HAVING IN conditions.

Purpose

havingIn() adds HAVING IN conditions. It lets a controller customize Aksara Core behavior while keeping the request inside the built-in CRUD, rendering, permission, validation, and response pipeline.

When to Use

Use it when a controller needs to shape the generated dataset before calling render() without creating a separate custom query flow.

Reference

havingIn(string|array $field = [], mixed $value = '', bool $escape = true)

Parameters

ParameterTypeRequiredDefaultDescription
$fieldstring|arrayNo[]Field name, field list, or associative field configuration.
$valuemixedNo''Value assigned to the given key or field.
$escapeboolNotrueWhether the database layer should escape identifiers and values.

Return Value

static

Returns the current controller instance so it can be chained with other Core methods.

Behavior

havingIn() records a query instruction on the controller. Core applies that instruction when render() compiles the final query. It does not execute a database query by itself.

Basic Usage

$this->havingIn('status', ['paid', 'processing']);

return $this->render('orders');

Advanced Usage

$this->select('orders.order_id, orders.order_number, customers.customer_name')
    ->join('customers', 'customers.customer_id = orders.customer_id', 'left')
    ->where('orders.deleted_at', null)
    ->orderBy('orders.created_at', 'DESC')
    ->limit(25);

return $this->render('orders');

Complete Example

namespace Modules\Orders\Controllers;

use Aksara\Laboratory\Core;

class Orders extends Core
{
    public function index()
    {
        $this->setTitle(phrase('Orders'))
            ->havingIn('status', ['paid', 'processing']);

        return $this->render('orders');
    }
}

Result

The final generated query includes this instruction before rows are serialized and rendered. API responses use the same prepared query.

Notes

  • This method is chainable and returns the current controller instance.
  • Call this before render() so the query instruction is available during query compilation.
  • Leave $escape enabled unless the expression has already been validated and intentionally needs raw SQL behavior.

Common Mistakes

  • Calling the method after render(), because the query has already been compiled.
  • Disabling escaping for untrusted request input.

Related Methods

Available Methods

addButton addClass addDropdown addField addFilter addSubmitButton addToolbar afterDelete afterInsert afterUpdate allowPublicFormSubmission allowTokenFrom beforeDelete beforeInsert beforeUpdate columnOrder columnSize databaseConfig debug defaultValue deleteBatch deleteData distinct fieldAppend fieldOrder fieldPosition fieldPrepend fieldSize formCallback from fromSubquery getMethod gridView groupBy groupEnd groupField groupStart having havingGroupEnd havingGroupStart havingIn havingLike havingNotIn ignoreQueryString insertData insertId itemReference join like limit mergeContent mergeField modalSize notGroupStart notHavingGroupStart notHavingLike notLike offset orGroupStart orHaving orHavingGroupStart orHavingIn orHavingLike orHavingNotIn orLike orNotGroupStart orNotHavingGroupStart orNotHavingLike orNotLike orWhere orWhereIn orWhereNotIn orderBy parentModule permitUpsert render renderForm renderRead renderTable restrictOnDemo searchable select selectAvg selectCount selectMax selectMin selectSubquery selectSum serialize serializeRow setAiContext setAlias setAttribute setAutocomplete setBreadcrumb setButton setDefault setDescription setField setHeading setIcon setMessages setMethod setOptionLabel setOutput setPermission setPlaceholder setPrimary setRelation setTemplate setTheme setTitle setTooltip setUploadPath setValidation sortable table unsetColumn unsetDelete unsetField unsetMethod unsetRead unsetSelect unsetToolbar unsetTruncate unsetUpdate unsetView updateData validToken validateForm verticalSchema viewOrder where whereIn whereNotIn