In Laravel I am fetching the value from database and based on that adding condition to check checkbox. I am facing issue with laravel checkbox is not getting checked. Tried using following code:
// outputting value from database to input field
{{Form::text('lock_user_role',null,array('class'=>'form-control')) }}
// if lock user value is 1 in database then need to check checkbox
{{Form::checkbox('lock_user_role', 'lock_user_role', 'lock_user_role' === '1' ? true : false)}}
Here is my database column structure:

Here is my column value getting stored:
Here is my actual output shown:
As shown in above image, value is showing 1 but checkbox is not getting checked. Can anyone correct my code ? Thanks


If the value fetched from database is integer 1 then the strict comparison (===) will evaluate to false.
Try replacing with loose comparison (==)
And comparison between string literal
lock_user_roleand any other string or integer will always be false'lock_user_role' == '1'will always evaluate to false - as pointed out by @TimLewis.So it should be something like
$user->lock_user_roleor$lock_user_role- a variable