In this section we will see how to use old selected value checkbox checked in laravel 9. For this section we will also see laravel @checked blade directives. before we start you need read below article.
How to Use Boolean Value in Laravel 9
Example 1
simple laravel checkbox selected with ternary operator.
<input type="checkbox" name="status" {{ $blog->status ? 'checked' : '' }}/>
laravel checkbox selected with ternary operator and compare boolean values.
<input type="checkbox" name="status" {{ $blog->status==1 ? 'checked': '' }}/>
laravel checkbox selected with ternary operator and compare boolean true , false value value.
<input type="checkbox" name="status" {{ $blog->status==true ? 'checked': '' }}/>
Example 2
laravel 9 select check box with @if blade directives.
<input type="checkbox" name="status" @if ($blog->status) checked @endif/>
Example 3
laravel 9 use checked box with latest @checked blade directives.
<input type="checkbox" name="status" @checked($blog->status)/>