コード例 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param CreateCourseRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(CreateCourseRequest $request)
 {
     $course = new Course();
     $course->fill($request->all());
     $course->user_id = Auth::user()->id;
     if ($request->hasFile('image')) {
         $file = $request->file('image');
         $patch = 'images/courses/';
         $name = $course->id . '.' . $file->getClientOriginalExtension();
         $image = $patch . $name;
         Image::make($file)->fit(650, 360)->save($image);
         $course->image = $image;
     }
     $course->save();
     $message = trans('messages.course_successfully_started');
     Flash::success($message);
     return redirect()->route('teacher.courses.show', $course);
 }
コード例 #2
0
 /**
  * Store a new course
  *
  * @param CreateCourseRequest $request
  * @return \Illuminate\Http\JsonResponse
  */
 public function store(CreateCourseRequest $request)
 {
     \Course::storeCourse(Auth::user(), $request->all());
     return redirect('/courses')->with(['message' => 'Курсот беше успешно креиран']);
 }