Hello I want to delete all the rows from the database which are being checked by the user but whenever I do this I get this error "Missing argument 1 for App\Http\Controllers\UploadController::deleteSelectedUploads()"
. I know why this error is coming because I haven't passed any id to it and if I pass any id to it then it says Undefined variable: upload
. Please help me out. I know I have been posting a lot of questions nowadays and later solve it on my own but this is the only way of learning I guess.
Controller
public function deleteSelectedUploads($id) {
//$uploads = $this->upload->get($id);
// $checkboxes = $this->request->input('checkbox[]');
// if((Auth::user()->role=='admin')) {
// $this->upload->deleteUpload($id);
// } else {
// Session::flash('message', "Oooopsss ... ! seems like you don't have the authority to
// <span style=font-weight:bold;'><u>DELETE</u></span> this file.
// <span style='font-size:15pt; font-weight:bold;'> Contact ADMIN </span>");
// return redirect('home');
// }
$checkbox = Input::all();
foreach($checkbox['checkbox'] as $id) {
Upload::where('id', $id)->delete();
}
Session::flash('message', 'You File has been deleted');
return redirect('home');
}
View
<th><form action="/delete-selected-uploads" method="get">
<input type="checkbox" name="checkbox" onClick="toggle(this)"/>
<input type="submit" class="btn btn-block btn-success btn-xs" value="Delete all checked">
</form>
</center>
</th>
<td>
<input type="checkbox" name="checkbox[]" id="" value="">
</td>
Route
Route::get('/delete-selected-uploads', 'UploadController@deleteSelectedUploads');
Aucun commentaire:
Enregistrer un commentaire