Question:
How to workaround limit of array size when using whereNotIn()? Laravel

Solution

You can try using left join and then that return result if the join value is null


public function scopeNotBlacklisted(Builder $query): void {

    $query->leftJoin('transactions as tr', function ( $join ) {

        $join->on('YOUR_WHATEVER_TABLE_HERE.phonenumber', '=', 'tr.phonenumber')

            ->where('tr.finalized_at', '>=', now()->subDays(365)->toDateString());

    })->whereNull('tr.phonenumber');

}


EDIT: An alternative approach that you could try would be to use >whereNotExists to perform a raw query in place of a left join.


public function scopeNotBlacklisted(Builder $query): void {

    $query->whereNotExists(function ($sub) {

        $sub->selectRaw('1')

        ->from('transactions as tr')

        ->where('tr.finalized_at', '>=', now()->subDays(365)->toDateString())

        ->whereColumn('tr.phonenumber', '=', 'YOUR_MAIN_TABLE.phonenumber');

    });

}


Suggested blogs:

>Building Web API using ASP.NET (C#)

>Built Web API using ASP.NET (C#)

>Built your simple Android App with Kotlin

>How to manage the Text in the container in Django?

>Activating Virtual environment in visual studio code windows 11

>Fix webapp stops working issue in Django- Python webapp

>Creating a form in Django to upload a picture from website

>Sending Audio file from Django to Vue

>How to keep all query parameters intact when changing page in Django?


Nisha Patel

Nisha Patel

Submit
0 Answers