当前位置: 首页>>代码示例>>PHP>>正文


PHP Course::save方法代码示例

本文整理汇总了PHP中app\Course::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::save方法的具体用法?PHP Course::save怎么用?PHP Course::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Course的用法示例。


在下文中一共展示了Course::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $course = new Course();
     $course->course_name = $request->course_name;
     $course->grade_level = $request->grade_level;
     //$course->school_id = '0';
     $course->save();
     return back()->with('status', sprintf("Successfully added %s", $request->course_name));
     //Validation Goes here
     /*
     $validator = Validator::make($request->all(), [
     	'course_name' => 'required',
     	'grade_level' => 'required',
     ]);
     
     var_dump($validator->fails());
     
     if($validator->fails()):
     	return back()
     		->withErrors($validator->errors())
     		->withInput();		
     else:
     
     	$course = new Course;
     	$course->course_name = $request->course_name;
     	$course->grade_level = $request->grade_level;
     	//$course->school_id = '0';
     	//$course->save();	
     
     	return back()->with('status', sprintf("Successfully added %s",$request->course_name));
     	
     endif;
     */
 }
开发者ID:purplenimbus,项目名称:Nimbus-SMS,代码行数:40,代码来源:CourseController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(CourseFormRequest $request)
 {
     $course = new Course(array('course_name' => $request->get('course_name'), 'introduction' => $request->get('introduction'), 'objectives' => $request->get('objectives'), 'course_contents' => $request->get('course_contents'), 'training_methods' => $request->get('training_methods'), 'participants' => $request->get('participants'), 'duration' => $request->get('duration'), 'academic_staff' => $request->get('academic_staff'), 'course_fee' => $request->get('course_fee'), 'accommodation_and_food' => $request->get('accommodation_and_food'), 'library' => $request->get('library'), 'award' => $request->get('award'), 'address_for_correspondence' => $request->get('address_for_correspondence'), 'training_id' => $request->get('training_id')));
     $course->save();
     $id = $request->get('id');
     return redirect('/courses')->with('Your course has been created!Its id is: ' . $id);
 }
开发者ID:NabanitaBiswas,项目名称:tms_bard-project-previous-,代码行数:13,代码来源:CourseController.php

示例3: create

 /**
  * Handles creation of new courses
  * @param Request $request
  * @return mixed
  */
 public function create(Request $request)
 {
     // Make sure that the all required fields are present
     if ($request->has('title') && $request->has('description') && $request->has('start_date') && $request->has('start_time') && $request->has('end_date') && $request->has('end_time') && $request->has('price') && $request->has('total_slots')) {
         // Make sure we have an active user
         if (Auth::check()) {
             // Retrieve the formdata from the request
             $formdata = $request->all();
             // Create a new course to fill with this info
             $course = new Course();
             // Apply the formdata to the new course
             $course->title = $formdata['title'];
             $course->description = $formdata['description'];
             $course->start = $formdata['start_date'] . ' ' . $formdata['start_time'];
             $course->end = $formdata['end_date'] . ' ' . $formdata['end_time'];
             $course->price = $formdata['price'];
             $course->total_slots = $formdata['total_slots'];
             $course->instructor_id = Auth::id();
             // Create the new course
             $course->save();
             // Redirect the user back to their homepage with a success message
             return Redirect::to('/home')->with('success', 'Course created successfully');
         }
     }
     // Redirect the user back to their homepage with a failure message
     return Redirect::to('/home')->with('error', 'Please fill out all required fields and try again');
 }
开发者ID:carbide20,项目名称:courses,代码行数:32,代码来源:CourseController.php

示例4: store

 public function store(Request $request)
 {
     $inputs = $request->all();
     $course = new Course();
     $course->fill($inputs);
     $course->save();
     return $course->id;
 }
开发者ID:Kangaroos,项目名称:restart-reserve,代码行数:8,代码来源:CourseController.php

示例5: store

 public function store(CourseRequest $request)
 {
     $course = new Course($request->only(['name']));
     $course->save();
     $course->users()->sync($request->input('users'));
     $course->teachers()->sync($request->input('teachers'));
     session()->flash('success', 'El curso se ha creado.');
     return redirect()->route('admin.course.edit', $course->id);
 }
开发者ID:abalozz,项目名称:glaciar,代码行数:9,代码来源:CoursesController.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(saveCourseRequest $request)
 {
     $course = new Course($request->except(['department', 'semester']));
     $department = Department::where('code', $request->input('department'))->first();
     $semester = Semester::find($request->input('semester'));
     $course->department()->associate($department);
     $course->semester()->associate($semester);
     $course->save();
     $request->session()->flash('status', 'Course was saved successful!');
     return back();
 }
开发者ID:arnabrahman,项目名称:Course-and-Result-Management,代码行数:17,代码来源:CourseController.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //dd($request->all());
     $course = new Course();
     $course->course_name = $request->input('course_name');
     $course->course_instructor = $request->input('course_instructor');
     $course->semester_id = $request->input('semester_id');
     $course->course_time_id = $request->input('course_time_id');
     $course->course_location = $request->input('course_location');
     $course->save();
     return redirect('courses');
 }
开发者ID:bigschlong69,项目名称:capstoneAll,代码行数:18,代码来源:CoursesController.php

示例8: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $crs = new Course();
     $crs->name = $request['name'];
     $crs->affiliateId = $request['affiliateId'];
     $crs->streamId = $request['streamId'];
     $crs->levelId = $request['levelId'];
     $crs->courseType = $request['courseType'];
     $crs->duration = $request['duration'];
     $crs->save();
     \Session::flash('sucess_message', 'Course is sucessfully created.');
     return redirect('myAdmin/courses');
 }
开发者ID:premsingh4github,项目名称:SchoolUmbrella,代码行数:19,代码来源:CourseController.php

示例9: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(CourseFormRequest $request)
 {
     $input = $request->course_image;
     if (isset($input)) {
         $Image = $this->imageUpload($input);
     } else {
         $Image = "course_img/default.jpg";
     }
     $course = new Course(array('course_name' => $request->get('course_name'), 'introduction' => $request->get('introduction'), 'objectives' => $request->get('objectives'), 'course_contents' => $request->get('course_contents'), 'training_methods' => $request->get('training_methods'), 'participants' => $request->get('participants'), 'duration' => $request->get('duration'), 'academic_staff' => $request->get('academic_staff'), 'course_fee' => $request->get('course_fee'), 'accommodation_and_food' => $request->get('accommodation_and_food'), 'library' => $request->get('library'), 'award' => $request->get('award'), 'address_for_correspondence' => $request->get('address_for_correspondence'), 'training_id' => $request->get('training_id'), 'course_image' => $Image));
     $course->save();
     $id = $request->get('id');
     return redirect('/create_course')->with('status', 'Your course has been created!');
 }
开发者ID:polodev,项目名称:Bard-Ftfl-Laravel-Project,代码行数:19,代码来源:CourseController.php

示例10: store

 public function store()
 {
     $request = json_decode(request()->getContent());
     $rules = array('name' => 'required|unique:courses', 'attendants' => 'required');
     $validation = Validator::make((array) $request, $rules);
     if ($validation->fails()) {
         return response()->json(array('error' => true, 'message' => $validation->errors()->all(), 200));
     }
     $course = new Course();
     $course->name = $request->name;
     $course->attendants = abs($request->attendants);
     $saved = $course->save();
     return response()->json(array('error' => !$saved, 'courses' => $course->toArray()), $saved ? 200 : 500);
 }
开发者ID:ibrohimislam,项目名称:roomate,代码行数:14,代码来源:CoursesController.php

示例11: registercourse

 public function registercourse()
 {
     $messages = array('course_code.required' => 'Code is required', 'course_code.unique' => 'This course is already registered', 'course_code.min' => 'Code must be at least 6 characters', 'course_code.max' => 'Code must be at most 8 characters', 'coursename.required' => 'Course name is required');
     $validator = Validator::make(Input::all(), ['course_code' => 'required|min:6|max:8|unique:courses', 'coursename' => 'required'], $messages);
     if ($validator->fails()) {
         return redirect('addcourse')->withInput()->withErrors($validator);
     }
     $course = new Course();
     $course->course_code = Input::get('course_code');
     $course->course_title = Input::get('coursename');
     $course->credit = Input::get('coursecredit');
     $course->save();
     return view('layouts.addcourse')->with('registermsg', "Course registered.");
 }
开发者ID:nikeshakya,项目名称:KU-SMS,代码行数:14,代码来源:CourseController.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $courses = new Course();
     $courses->program_study_id = Input::get('program_study_id');
     $courses->course_code = Input::get('course_code');
     $courses->course_name = Input::get('course_name');
     $courses->semester = Input::get('semester');
     $courses->credits = Input::get('credits');
     $courses->faculty_code = Input::get('faculty_code');
     $courses->study_id = Input::get('study_id');
     $courses->save();
     Session::flash('message', 'You have successfully added course');
     return Redirect::to('dashboard/admin/courses');
 }
开发者ID:nurulimamnotes,项目名称:tutasiak,代码行数:19,代码来源:CourseController.php

示例13: storeCourse

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function storeCourse(Request $request)
 {
     $data = Request::all();
     if (Course::find($data['scourse'])) {
         return back()->withInput();
     } else {
         $course = new Course();
         $course->college = $data['college'];
         $course->scourse = $data['scourse'];
         $course->course = $data['course'];
         $course->campus = $data['campus'];
         $course->save();
         return Redirect::to('/admin');
     }
 }
开发者ID:jMelgar101,项目名称:Classnotch,代码行数:20,代码来源:NoteBookController.php

示例14: add_course

 /**
  * Save request info as new course in database.
  *
  * @param  Request  $request
  * @return Response
  */
 public function add_course(Request $request)
 {
     $check = DB::table('courses')->where('department', '=', '$request->department')->where('number', '=', '$request->number')->first();
     if (!empty($check)) {
         $data = array('old' => $request);
         session()->put('error', 'Course with department and number already exists.');
         return view('course_add', $data);
     }
     $course = new Course();
     $course->department = $request->department;
     $course->number = $request->number;
     $course->description = $request->description;
     $course->save();
     session()->put('success', 'Course has been added.');
     return redirect('/course/' . $course->id);
 }
开发者ID:Calvin-TMO,项目名称:TMO,代码行数:22,代码来源:CourseController.php

示例15: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //dd($request->all());
     $this->validate($request, ['slug' => 'unique:courses,slug', 'name' => 'required', 'short_description' => 'required', 'description' => 'required', 'date_start' => 'required|date|after:today', 'date_end' => 'required|date|after:date_start', 'min_participants' => 'required|integer', 'max_participants' => 'required|integer', 'price' => 'required|integer']);
     $course = new Course();
     if ($request->hasFile('featured_image')) {
         $featured_image = $course->uploadImage($request->featured_image);
     }
     $course->fill($request->all());
     if (isset($featured_image)) {
         $course->featured_image = $featured_image;
     }
     $course->save();
     Session::flash('flash_message', 'Námskeiðið var vistað');
     return redirect()->back();
 }
开发者ID:dadigu,项目名称:haskolabru,代码行数:22,代码来源:CoursesController.php


注:本文中的app\Course::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。