/** * Run the database seeds. * * @return void */ public function run() { // //DB::table('students')->delete(); $student1 = student::create(['name' => 'aul', 'major' => 'IF']); $student2 = student::create(['name' => 'lala', 'major' => 'IF']); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // $student = student::findOrFail($id); //echo $student; return view('students.show', compact('student')); }
public function run() { $faker = faker::create(); $students = student::all()->lists('id'); $course = ['physics', 'math', 'english', 'data structure', 'A.I']; foreach (range(1, 30) as $index) { course::create(array('student_id' => $faker->randomElement($students), 'course_name' => $faker->randomElement($course), 'created_at' => $faker->dateTimeBetween('now', '+14 days'))); } }
public function add_stud(Request $request) { $input = $request->all(); $input['created_at'] = Carbon::now(); $input['updated_at'] = Carbon::now(); student::create($input); $values = DB::select("select sf.code, fid from subfacrels as sf inner join subjects as s on sf.code = s.code where sem like '%" . $input['sem'] . "%' and branch like '%" . $input['branch'] . "%' and secs like '%" . $input['section'] . "%'"); foreach ($values as $key => $value) { DB::insert('insert into relations (enid, code, fid, attended, total, created_at, updated_at) values (?, ?, ?, ?, ?, ?, ?)', [$input['enid'], $value->code, $value->fid, 0, 0, Carbon::now(), Carbon::now()]); } return view('admin.admin_master'); }
public function run() { DB::table('students')->truncate(); $skip = 0; $reader = Reader::createFromPath(base_path() . '/database/seeds/students.csv'); foreach ($reader as $index => $row) { if ($skip) { student::create(['teamStyle' => $row[5], 'c' => $row[6], 'java' => $row[7], 'python' => $row[8], 'twoHundreds' => $row[9], 'threeHundreds' => $row[10], 'fourHundreds' => $row[11]]); } else { $skip = 1; } } }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { \App\student::create([]); return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'admin' => false]); }
public function makeTeams(Request $request) { //delete all from teams and teamMembers DB::table('teams')->truncate(); DB::table('teamMembers')->truncate(); //put all students into array $students = \App\student::all(); $comp = array(); $sosh = array(); $donkeyKong = array(); foreach ($students as $student) { $student->skill = 4 * $student->fourHundreds + 3 * $student->threeHundreds + 2 * $student->twoHundreds; if ($student->teamStyle == "competitive") { array_push($comp, $student); } elseif ($student->teamStyle == "social") { array_push($sosh, $student); } else { array_push($donkeyKong, $student); } } $id = 1; //sort arrays by skill $comp = collect($comp)->sortBy('skill'); $sosh = collect($sosh)->sortBy('skill'); $donkeyKong = collect($donkeyKong)->sortBy('skill'); $teams = $this->algorithm($comp, intval($request->max), intval($request->min)); for ($i = 1; $i < count($teams); $i = $i + 1) { $c = 0; $j = 0; $p = 0; foreach ($teams[$i] as $student) { $c = $c + intval($student->c); $j = $j + intval($student->java); $p = $p + intval($student->python); } DB::table('teams')->insert(array('name' => "Team " . $id, 'c' => $c, 'java' => $j, 'python' => $p, 'type' => 'Competitive')); foreach ($teams[$i] as $student) { DB::table('teamMembers')->insert(array('studentId' => $student->id, 'teamId' => $id)); } $id = $id + 1; } foreach ($teams[0] as $student) { DB::table('teamMembers')->insert(array('studentId' => $student->id, 'teamId' => 0)); } $teams = $this->algorithm($sosh, $request->max, $request->min); for ($i = 1; $i < count($teams); $i = $i + 1) { $c = 0; $j = 0; $p = 0; foreach ($teams[$i] as $student) { $c = $c + intval($student->c); $j = $j + intval($student->java); $p = $p + intval($student->python); } DB::table('teams')->insert(array('name' => "Team " . $id, 'c' => $c, 'java' => $j, 'python' => $p, 'type' => 'Social')); foreach ($teams[$i] as $student) { DB::table('teamMembers')->insert(array('studentId' => $student->id, 'teamId' => $id)); } $id = $id + 1; } foreach ($teams[0] as $student) { DB::table('teamMembers')->insert(array('studentId' => $student->id, 'teamId' => 0)); } $teams = $this->algorithm($donkeyKong, $request->max, $request->min); for ($i = 1; $i < count($teams); $i = $i + 1) { $c = 0; $j = 0; $p = 0; foreach ($teams[$i] as $student) { $c = $c + intval($student->c); $j = $j + intval($student->java); $p = $p + intval($student->python); } DB::table('teams')->insert(array('name' => "Team " . $id, 'c' => $c, 'java' => $j, 'python' => $p, 'type' => "Don't Care")); foreach ($teams[$i] as $student) { DB::table('teamMembers')->insert(array('studentId' => $student->id, 'teamId' => $id)); } $id = $id + 1; } foreach ($teams[0] as $student) { DB::table('teamMembers')->insert(array('studentId' => $student->id, 'teamId' => 0)); } return Redirect::back(); }
public function index() { $data = student::with('courses', 'guardians')->paginate(3); $data->setPath('student'); return View('student')->with('student', $data); }
public function shownew(Requests\NewStudentRequest $request) { student::create($request->all()); return redirect('/'); }