laravel/framework — pull request #3021 by alexandre-butynski (2013-12-22 20:49:40+00:00)
Title: Form checkbox builder deal with model relationships

First of all, there is a bug fix. When a checkbox had the same name than a model relation, the state of the checkbox was incoherent because the method `getCheckboxCheckedState` was not designed for this use case :

```PHP
// Old method. If $name is the name of a has many relationships, $posted is an instance of Collection and the method return true
$posted = $this->getValueAttribute($name);

return is_array($posted) ? in_array($value, $posted) : (bool) $posted;
```
Hard to debug... An other issue of this method is that no default value is given to `getValueAttribute`, even if the `$checked` argument is set in the `Form::checkbox` method. In the case where the checkbox had the same name than the model relation, the "checked" state manually defined was not considered.

Then, you can see my solution below. Because I was dealing with form model relationships here, I took the opportunity to improve the method and automatically set the checkbox to the good state. I think it's a common use case.

Just say if there is a misunderstanding or if this could be improved. Should be merged with `4.1` and `master` branches too.