Wednesday, March 15, 2017

How do you set a boolean for whether a record exists in Laravel?

I'm trying to set a boolean $bln according to whether a record exists in a table.

This is what I've been trying:

$bln = (bool) DB::table('accounts')->where('name', $name)->pluck('id');

For some reason $bln always seems to be set to true. What am I doing wrong?



via Urbycoz

Advertisement