Laravel Insert Update Delete Multiple checkbox value Example

Laravel Redirect To Another URL / Web Page - HTTP Laravel Redirects

Today, We want to share with you Laravel Insert Update Delete Multiple checkbox value Example.In this post we will show you Update/Delete Multiple checkboxes using laravel, hear for Multiple check boxes in an update form using Laravel we will give you demo and example for implement.In this post, we will learn about Update multiple rows using multiple select menu inputs with an example.

Laravel Insert Update Delete Multiple checkbox value Example

There are the Following The simple About Laravel Insert Update Delete Multiple checkbox value Example Full Information With Example and source code.

Read Also:  Vuejs Live Search Filter Example with Demo

As I will cover this Post with live Working example to develop Laravel update multiple value at once, so the some major insert multiple checkbox value in database for this example is following below.

Example 1 : Laravel Multiple checkbox Insert

How the Store multiple checkbox values to Mysql database in laravel

app/controllers/MemberController.php

public function store(Request $request)
{
      request()->validate([
                'name' => 'required|string',
            ], [
                'name.required' => 'Member Name is required',
            ]);

            Members::create([
                'name' => $request['name'],
                'category_ids' => json_encode($request['category_ids']),
            ]);
            return redirect('members')->with('success','Members created successfully.');
}

public function create()
{
    $categorieslist = DB::table('categories')->whereNull('deleted_at')->pluck("name","id");
    return view('members.create',compact('categorieslist'));
}

resources/views/members/create.blade.php

<div class="control-group">
    <label class="control-label" for="Category">Category:</label>
    <div class="controls">
        
            @foreach ($categorieslist as $cat => $value)
                 {{ $value }}
            @endforeach
        
    </div> <!-- /controls -->
</div> <!-- /control-group -->

Example 2 : Multiple checkbox update in Laravel

simple laravel unchecked if checkbox get It’s ids and save state “0”

Read Also:  how to create horizontal tabs in html?

resources/views/members/edit.blade.php

    <div class="control-group">
        <label class="control-label" for="Category">Category:</label>
        <div class="controls">
            
                @foreach ($categorieslist as $cat => $value)
                    cat_ids, $cat)) selected @endif> {{ $value }}
                @endforeach
            
        </div> <!-- /controls -->
    </div> <!-- /control-group -->

app/controllers/MemberController.php

public function edit($id)
{
    $members = \App\Members::find($id);

    $categorieslist = DB::table('categories')->whereNull('deleted_at')->pluck("name","id");
    return view('members.edit',compact('members','id','roles','categorieslist'));
}
public function update(Request $request, $id)
{
    $members= \App\Members::find($id);
    $members->name=$request->get('name');
    $members->email=$request->get('email');
    $users->category_ids=json_encode($request->get('category_ids'));
    $users->save();
    return redirect('members')
        ->with('success','Member updated successfully.');
}

Example 3 : Multiple checkbox Delete in Laravel

app/Http/Controllers/MemberController.php

Read Also:  How to make a comment box in bootstrap?

Laravel delete multiple records using checkbox

public function deleteAll(Request $request)
{
    $ids = $request->ids;
    DB::table("members")->whereIn('id',explode(",",$ids))->delete();
    return response()->json(['success'=>"Members Deleted successfully."]);
}

routes/web.php

Route::delete('membersDeleteAll', '[email protected]');

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Laravel Insert Update Delete Multiple checkbox value Example.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

About Pakainfo

I am Jaydeep Gondaliya, a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Pakainfo →

Leave a Reply

Your email address will not be published. Required fields are marked *