当前位置: 首页>>代码示例>>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;未经允许,请勿转载。