<?php
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();

$search = "Jannah"; 
$query = App\Models\Peminjaman::where(function($q) use ($search) {
    $q->whereHas('user', function($qUser) use ($search) {
        $qUser->where('name', 'like', "%{$search}%");
    })->orWhereHas('buku', function($qBuku) use ($search) {
        $qBuku->where('judul', 'like', "%{$search}%");
    });
});
echo $query->toSql() . PHP_EOL;
print_r($query->getBindings());
echo "Count: " . $query->count() . PHP_EOL;
