laravel 5 query where not has

Just a quick way to get a count of related models. There actually is not function called ->whereNotHas(), only ->whereHas() and ->has() so you can use ->has(). The code gets a count of users without an assigned role, this is just an example but shows how it can be done.

Sam Deering is a web developer from England (currently living in Australia). In his spare time he enjoys coding, playing chess, reading and investing.

One thought on “laravel 5 query where not has

Leave a Reply

Your email address will not be published. Required fields are marked *