public function postDeleteSections() { $section_id = Input::get('section_id'); $section_name = Input::get('section_name'); $class_id = Input::get('class_id'); if ($section_id) { $sections = Sections::find($section_id); } else { $sections = Sections::where('section_name', '=', $section_name)->where('class_id', '=', $class_id); } if ($sections->delete()) { $response = array('status' => 'success', 'msg' => 'Setting created successfully', 'deleted_item_id' => $section_id); return Response::json($response); } else { $response = array('status' => 'failed', 'msg' => 'Item is Not deleted', 'Item_id' => $section_id); return Response::json($response); } }
public function getDelete($id = '') { if ($id == '') { return Redirect::to($this->route)->with('msg_error', Lang::get('messages.sections_display_err')); } else { $section = Sections::find($id); $delete = Sections::destroy($id); if (!$delete) { return Redirect::to($this->route . '/trash')->with('msg_error', Lang::get('messages.sections_delete_err', array('title' => $section->title, 'description' => $section->description, 'file' => $section->file))); } else { return Redirect::to($this->route . '/trash')->with('msg_success', Lang::get('messages.sections_delete', array('title' => $section->title, 'description' => $section->description, 'file' => $section->file))); } } }
public function getSchoolStudents() { $query = "select\n users.id,\n users.school_id,\n user_details.username,\n user_details.first_name,\n user_details.last_name,\n users_to_class.class_id,\n users_to_class.section_id,\n user_details.pic\n from users\n join users_groups\n on users.id=users_groups.user_id and users_groups.groups_id=? and users.school_id=?\n join user_details\n on users.id=user_details.user_id\n join users_to_class\n on users_to_class.user_id=users.id"; $all_school_users = DB::select($query, array(2, $this->getSchoolId())); $i = 0; foreach ($all_school_users as $all_school_user) { $class = Classes::find($all_school_user->class_id)->get()->first(); $all_users[$i]['class_name'] = $class->class; $section = Sections::find($all_school_user->section_id); $all_users[$i]['section_name'] = $section->section_name; $all_users[$i]['username'] = $all_school_user->username; $all_users[$i]['first_name'] = $all_school_user->first_name; $all_users[$i]['last_name'] = $all_school_user->last_name; $all_users[$i]['pic'] = $all_school_user->pic; $all_users[$i]['id'] = $all_school_user->id; $all_users[$i]['school_id'] = $all_school_user->school_id; $i++; } return View::make('admin.school-students')->with('users', $all_users); }