The third argument in the form builder's checkbox method is the checked attribute.
This
$user_profile->modules->where('module_id','=',$m->id)
returns a true value in each case thus you end up with all checkboxes being checked. Investigate the reason why that statement returns true value all the time.
My guess is that you have to append the whole query with a ->get() method. Then wrap the whole thing in a count(). Count will return 0 if no result has matched your query.
Die and dump this
$user_profile->modules->where('module_id','=',$m->id)
You should see that it outputs something other than a falsy value no matter of the database.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community