/** * Adds all the selected entries to the agents model * and redirects to the agents page * * @return Redirect */ public function onAccept() { if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) { foreach ($checkedIds as $item) { $item = explode(post('delimiter'), $item); $agent = new Agent(); $agent->name = $item[0]; $agent->comment = $item[1]; if (Agent::whereName($item[0])->count() > 0) { continue; } $agent->save(); } Flash::success('Successfully Added Items'); } return Redirect::to('backend/mohsin/txt/agents'); }