andFilter

An additional `where` parameter to the `with()` method. Placement of this method is before the `->with()` method.

andFilter([
    'relational-table' => "additonal-where-parameters"
])

// using the andFilter to filter the relational-table "tbl_task"
Route::get('/get-user-task', function () {

    $userid = Auth::user('id');
    $projectCode = 'J6K5L4MB21';

    $tasks = DB()->selectLoop("*","tbl_task_member", "projectCode = '$projectCode' and user_id = '$userid'")
        ->andFilter([
            "tbl_task" => "status = 2 and priority_stats = 2"
        ])
        ->with([
            "tbl_task" => ['task_id', 'task_id'],
            "roles" => ['user_id', 'id']
        ])->get();

    dd($tasks);

});

Last updated