本文整理汇总了PHP中app\Course::fill方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::fill方法的具体用法?PHP Course::fill怎么用?PHP Course::fill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Course
的用法示例。
在下文中一共展示了Course::fill方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
public function store(Request $request)
{
$inputs = $request->all();
$course = new Course();
$course->fill($inputs);
$course->save();
return $course->id;
}
示例2: 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();
}
示例3: store
/**
* 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);
}