How can we add where clause on table joins or simple tables in any datagrid in Bagisto?

  • For Simple Table -

    $queryBuilder = DB::table('table_name')
    ->addSelect('column_name1', 'column_name2', ...)
    ->where('condition', condition_value);

    For Table Joins -
    $queryBuilder = DB::table('table_name1')
    ->leftJoin('table_name2', function($leftJoin) {
    $leftJoin->on('table_name2.table_name2_column', '=', 'table_name1.table_name1_column')
    ->where('table_name2.table_name2_column_for_condtion', 'condition_value');
    You can change type of join according to your need. You can also see datagrid code for it, we have applied joins for some datagrids.

Log in to reply