本文整理汇总了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();
}
示例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));
}
}
示例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'));
}
示例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');
}