You can use column names in where clause to make dynamic where clauses. In the following example, we use whereName('John') instead of where('name', 'John').
<?php
namespace App\Http\Controllers;
use App\Models\User;
class UserController extends Controller
{
public function example()
{
return User::whereName('John')->get();
}
}