/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(createSubjectRequest $request) { $subject = new Subject(); $subject->create($request->all()); session()->flash('flash_message', 'Subject successfully added.'); return redirect('settings/subjects'); }
/** * Run the database seeds. * * @return void */ public function run() { Subject::create(['name' => 'Engineering Technology', 'code' => '065', 'abbreviation' => 'ET', 'category_id' => 1]); Subject::create(['name' => 'Biosystem Technology', 'code' => '066', 'abbreviation' => 'BT', 'category_id' => 1]); Subject::create(['name' => 'Science For Technology', 'code' => '067', 'abbreviation' => 'SFT', 'category_id' => 1]); Subject::create(['name' => 'Physics', 'code' => '001', 'abbreviation' => 'PHY', 'category_id' => 2]); Subject::create(['name' => 'Chemistry', 'code' => '002', 'abbreviation' => 'CHM', 'category_id' => 2]); }
/** * Run the database seeds. * * @return void */ public function run() { $subjects = ['Toán', 'Lý', 'Hoá', 'Sinh', 'Văn', 'Sử', 'Địa', 'Tiếng Anh', 'Tiếng Pháp', 'Tiếng Nga', 'Tiếng Nhật', 'Tiếng Đức', 'Tin Học']; foreach ($subjects as $key => $value) { $subject = Subject::create(['key' => Common::createKeyURL($value), 'priority' => 0, 'is_publish' => 1, 'created_by' => 'vankhoe', 'updated_by' => 'vankhoe']); SubjectTranslation::create(['subject_id' => $subject->id, 'locale' => 'vi', 'name' => $value]); } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, ['name' => 'required|min:5']); $input = $request->all(); Subject::create($input); \Session::flash('flash_message', 'Предметът беше успешно добавен!'); return redirect()->route('admin.subject.index'); }
/** * Init data subject */ public function seedSubject() { $drafts = Draft::all(); foreach ($drafts as $index => $draft) { $maMH = $draft->maMH; /** * Kiểm tra xem mã môn học đã có chưa? */ $subjects = Subject::all()->where('maMH', $maMH); if ($subjects->count() == 0) { $s = Subject::create(['name' => $draft->tenMH, 'maMH' => $draft->maMH, 'soTin' => $draft->soTin]); var_dump($s->name); } } }
public function insert($data) { // Validating data $validator = Validator::make($data, Subject::createrules()); // If there are no errors in data if (!$validator->fails()) { // Create Subject $subject = Subject::create($data); // Passing data to response service return $this->responseService->returnMessage($subject, 'Subject was not Inserted.'); } else { // Data has errors // Passing errors to response service return $this->responseService->errorMessage($validator->errors()->all()); } }
/** * Run the database seeds. * * @return void */ public function run() { // DB::table('subjects')->truncate(); Subject::create(['subject' => 'English', 'status_id' => 1]); Subject::create(['subject' => 'Mathematics', 'status_id' => 1]); Subject::create(['subject' => 'Physics', 'status_id' => 1]); Subject::create(['subject' => 'Biology', 'status_id' => 1]); Subject::create(['subject' => 'Chemistry', 'status_id' => 1]); Subject::create(['subject' => 'Introductory Technology', 'status_id' => 1]); Subject::create(['subject' => 'Agricultural Science', 'status_id' => 1]); Subject::create(['subject' => 'Geography', 'status_id' => 1]); Subject::create(['subject' => 'Fine Arts', 'status_id' => 1]); Subject::create(['subject' => 'French', 'status_id' => 1]); Subject::create(['subject' => 'Yoruba', 'status_id' => 1]); Subject::create(['subject' => 'Hausa', 'status_id' => 1]); Subject::create(['subject' => 'Igbo', 'status_id' => 1]); Subject::create(['subject' => 'Economics', 'status_id' => 1]); }
public function run() { $faker = Faker::create('ru_RU'); DB::table('subjects')->truncate(); Subject::create(['subject' => 'Биология', 'status' => 1]); Subject::create(['subject' => 'География', 'status' => 1]); Subject::create(['subject' => 'Иностранный язык', 'status' => 1]); Subject::create(['subject' => 'Информатика и ИКТ', 'status' => 1]); Subject::create(['subject' => 'Искусство', 'status' => 1]); Subject::create(['subject' => 'История', 'status' => 1]); Subject::create(['subject' => 'Литература', 'status' => 1]); Subject::create(['subject' => 'Математика', 'status' => 1]); Subject::create(['subject' => 'ОБЖ', 'status' => 1]); Subject::create(['subject' => 'Обществознание', 'status' => 1]); Subject::create(['subject' => 'Окружающий мир', 'status' => 1]); Subject::create(['subject' => 'Природоведение', 'status' => 1]); Subject::create(['subject' => 'Русский язык', 'status' => 1]); Subject::create(['subject' => 'Технология', 'status' => 1]); Subject::create(['subject' => 'Физика', 'status' => 1]); Subject::create(['subject' => 'Физическая культура', 'status' => 1]); Subject::create(['subject' => 'Химия', 'status' => 1]); }
/** * Parse all the courses into Course Objects and save in the database. */ private function parseCourses() { $courses = $this->getCourses(); foreach ($courses as $course) { $number = $course['catalog'][0]; $title = $course['coursetitle'][0]; $subject_code = $course['subject'][0]; try { $subject_title = $course['subjecttitle'][0]; $subject_title = str_replace('Augustana Faculty - ', '', $subject_title); Subject::create(['code' => $subject_code, 'name' => $subject_title]); } catch (Exception $e) { // print("Subject ".$subject_code." already exists.\n"); } $attributes = ['subject_code' => $subject_code, 'number' => $number, 'title' => $title]; try { $course = Course::firstOrNew($attributes); $course->offered_this_semester = true; $course->save(); } catch (Exception $e) { print "Course " . $subject_code . $number . " already exists.\n"; } } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $subjects = Subject::create(['subject' => ucwords($request->subjectCreate)]); return redirect('principal/create#subject-tab')->withInput(); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { //$this->validate($request, ['name' => 'required']); // Uncomment and modify if you need to validate any input. Subject::create($request->all()); return redirect('subject'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, ['name' => 'required|unique:subject']); $subject = Subject::create(['name' => $request->name]); return redirect('subject'); }
/** * Store a csv created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function import(Request $request) { if ($request->file('csv-file')->isValid()) { $csv_file = $request->file('csv-file'); if ("text/csv" == $csv_file->getClientMimeType()) { $dest_path = storage_path('temp'); $file_name = time() . '_' . str_replace(" ", "_", $csv_file->getClientOriginalName()); $csv_file->move($dest_path, $file_name); $fname = $dest_path . '/' . $file_name; $file = fopen($fname, "r"); $flash_message = []; $flash_error = 0; while (!feof($file)) { $tmp_data = fgetcsv($file); $item['code'] = !empty($tmp_data[0]) ? $tmp_data[0] : ''; $item['name'] = !empty($tmp_data[1]) ? $tmp_data[1] : ''; $item['description'] = !empty($tmp_data[2]) ? $tmp_data[2] : ''; $item['units'] = !empty($tmp_data[3]) ? $tmp_data[3] : '0'; $item['lec_hours'] = !empty($tmp_data[4]) ? $tmp_data[4] : '0'; $item['lab_hours'] = !empty($tmp_data[5]) ? $tmp_data[5] : '0'; $item['feature_id'] = !empty($tmp_data[6]) ? $tmp_data[6] : '1'; $v = Validator::make($item, ['code' => 'required|unique:subjects|max:20', 'name' => 'required|max:254', 'units' => 'integer|max:100', 'lec_hours' => 'numeric|max:999', 'lab_hours' => 'numeric|max:999', 'feature_id' => 'integer|min:1']); if (!$v->fails()) { Subject::create($item); $flash_message['success'][] = '[' . $item['code'] . '] ' . $item['name']; } else { $flash_error++; $flash_message['error'] = $flash_error; } } \Session::flash('flash_message', $flash_message); fclose($file); chmod($fname, 0777); unlink($fname); } } return redirect('/subjects'); }