當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Course::create方法代碼示例

本文整理匯總了PHP中app\models\Course::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP Course::create方法的具體用法?PHP Course::create怎麽用?PHP Course::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\Course的用法示例。


在下文中一共展示了Course::create方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: postCreate

 public function postCreate(Request $request)
 {
     $input = $request->only(['year', 'name']);
     $input['user_id'] = Auth::id();
     Course::create($input);
     flash()->success('Kurz bol vytvorený');
     return redirect()->back();
 }
開發者ID:psiskova,項目名稱:blog-academy,代碼行數:8,代碼來源:CourseController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Request::all();
     $validation = Course::validate($input);
     if ($validation->fails()) {
         $message = $validation->messages()->first();
         return Response()->json(ResponseManager::getError('', 10, $message));
     }
     $course = Course::create($input);
     if ($course) {
         $message = 'Added Successfully.';
         return Response()->json(ResponseManager::getResult($course, 10, $message));
     } else {
         $message = 'Something went wrong. Please try again.';
         return Response()->json(ResponseManager::getError('', 10, $message));
     }
 }
開發者ID:GaurangGhinaiya,項目名稱:Laravel-Angular-Demo,代碼行數:22,代碼來源:CourseController.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $image = Input::file('image');
     $filename = Hash::make(time()) . '.' . $image->getClientOriginalExtension();
     $path = '/images/courses/';
     $moveDirectory = public_path($path);
     $image->move($moveDirectory, $filename);
     /* Resize image if it width is more than 400px */
     if (Image::make($moveDirectory . $filename)->width() > 400) {
         $image = Image::make($moveDirectory . $filename);
         $image->resize(300, null, function ($constraint) {
             $constraint->aspectRatio();
         });
         $image->save($moveDirectory . $filename);
     }
     /* Create new course */
     Course::create(['title' => $request->title, 'description' => $request->description, 'image' => $path . $filename, 'user_id' => $request->user()->id]);
     flash()->success('Ви успішно добавили новий курс!');
     return redirect(route('courses'));
 }
開發者ID:Retsediv,項目名稱:edu,代碼行數:26,代碼來源:CoursesController.php

示例4: store

 /**
  * Store a newly created Course in storage.
  *
  * @param  CourseRequest  $request
  * @return Response
  */
 public function store(CourseRequest $request)
 {
     Course::create(['code' => $request->code, 'name' => $request->name, 'semester' => $request->semester, 'credit' => $request->credit, 'description' => e($this->htmlEditor->parseHtml($request->description))]);
     Flash::success('Course created successfully.');
     return redirect('/admin/course');
 }
開發者ID:TawsifKarim,項目名稱:ict-mbstu,代碼行數:12,代碼來源:CourseController.php


注:本文中的app\models\Course::create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。