How to store checkbox values if check box is in foreach loop (laravel)

Posted 1 year ago by irankhosravi

I have List of the infraction and All infraction is print in a foreach loop. I want to store some infraction id in the database using checkbox.

<table class="table table-bordered">
    @foreach($infractions as $infraction)
           <th>{{ $infraction->title }}</th>
               <input type="checkbox" value="1" name="infraction{{ $infraction->id }}" data-toggle="toggle" data-on="Yes" data-off="No" data-onstyle="success" data-offstyle="danger">
               <input type="hidden" name="infraction_name{{ $infraction->id }}" value="{{ $infraction->id }}" />

I have no idea where I put submit button and how to get value from a checkbox into Controller to save data.

public function store(Request $request)
    for(int i=0;i<68;i++){
        $query="insert into inspection ('title') value ($infraction->id)";

I want to change php (a example) to laravel.

Please sign in or create an account to participate in this conversation.