The checkbox is checked or unchecked in the Blade file in Laravel

In this tutorial, I will give you an example of “How to show if the checkbox is checked or unchecked in edit blade file in Laravel“, So you can easily apply it with your laravel 5, laravel 6, laravel 7, laravel 8.

Let’s see an example of The checkbox is checked or unchecked in the Blade file in Laravel

checkbox is checked or not in blade file in laravel

create.blade.php:-

<form>
<div>
<input type="checkbox"  name="terms_conditions" value="1">
</div>
</form

Controller:-

 public function store(Request $request)
 {
     $data= new ModelName();
     $data->name = $request->name;
     $data->email = $request->email;
     $data->terms_conditions_check = isset($request['terms_conditions']) ?  : '0';
     $data->save();
 }

edit.blade.php:-

<form>
<div>
<input type="checkbox" name="terms_conditions" {{ ($editData->terms_conditions_check == '1') ? "checked" : "" }} value="{{ $editData->terms_conditions_check }}>
</div>
</form>

Related article:- Check if a checkbox is checked or not using Jquery.

In this article, we learned “How to Handle checked or unchecked checkboxes in Laravel”, I hope this article will help you with your Laravel application Project.

Read also:- Edit data in a model in the Laravel model using Ajax.

Hi, My name is Gaurav Pandey. I'm a Laravel developer, owner of 8Bityard. I live in Uttarakhand - India and I love to write tutorials and tips that can help other developers. I am a big fan of PHP, Javascript, JQuery, Laravel, WordPress. connect@8bityard.com