Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.0] Cast boolean values to appropriate string #713

Merged
merged 2 commits into from
Jan 7, 2020

Conversation

browner12
Copy link
Contributor

boolean true cast to a string is "1", while boolean false cast to a string is an empty string.

If you try to select an element that your model has set as false it will most likely fail because the value of your <option> will not be an empty string

class Site extends Model
{
    $casts = [
        'enabled' => 'boolean',
    ];
}

$browser->select('enabled', $site->enabled);
 <select name="enabled">
    @foreach(['no', 'yes'] as $key => $option)
        <option value="{{ $key }}">{{ ucwords($option) }}</option>
    @endforeach
</select>

browner12 and others added 2 commits January 6, 2020 16:29
cast boolean value to their appropriate string integer value.
@taylorotwell taylorotwell merged commit 61d9cfb into laravel:5.0 Jan 7, 2020
@browner12 browner12 deleted the patch-1 branch January 7, 2020 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants