How can i delete users by chosing them with checkboxes

Posted 10 months ago by uhbc

Here is how the table looks like:


                                            <td><a href="javascript:;" onclick="if(confirm('Are you sure you wanna delete the user?'))location.href='{{route('deleteuser',array('id'=>$row->id))}}'">Delete it!</a></td>


Route::get('/user/delete/{id}', '[email protected]')->name('deleteuser');

Here is, how the UserController looks like:

public function delete($id){
        if (\Auth::user()->role != 'admin')
            return \Redirect::to('/home');
        $status = \DB::delete('delete from users where id=?',array($id));
            return \Redirect::to(route('allusers',array('info'=>'Account deleted')));
            return \Redirect::to(route('allusers',array('error'=>'An error occured, try again later.')));

The question here is; When I click on the "Delete it!", it deletes the account. But the thing I want is, when I chose the checkboxes under 'Multiple tasks' and click on a button, remove the chosen ones from DB. How can I do that?

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

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.