本文整理汇总了PHP中app\Course::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::findOrFail方法的具体用法?PHP Course::findOrFail怎么用?PHP Course::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Course
的用法示例。
在下文中一共展示了Course::findOrFail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$course = Course::findOrFail($id);
$course->delete();
Session::flash('message', 'Successfully Deleted your Data!');
return redirect()->back();
}
示例2: destroy
public function destroy($id)
{
$course = Course::findOrFail($id);
$course->delete();
session()->flash('success', 'El curso ' . $course->name . ' se ha eliminado.');
return redirect()->route('admin.course.index');
}
示例3: training
/**
* Show training page for registration
*
* @param $id
*
* @return $this
*/
public function training($id)
{
if (isset($id)) {
$course = Course::findOrFail($id);
}
$data = ['title' => 'Teleaus | Training Page', 'parentPage' => 'Recources', 'page' => 'Registration form ', 'course' => count($course) ? $course : 0];
return view('training-form')->with($data);
}
示例4: store
public function store(ContentRequest $request)
{
$course = Course::findOrFail($request->input('course_id'));
$this->authorize('manage-course-contents', $course);
$content = new Content($request->only(['title', 'body']));
$content->course()->associate($course);
$content->save();
session()->flash('success', 'El contenido se ha publicado.');
return redirect()->route('content.edit', $content->id);
}
示例5: store
public function store(QuestionRequest $request)
{
$course = Course::findOrFail($request->input('course_id'));
$this->authorize('view-course', $course);
$question = new Question($request->only(['title', 'body']));
$question->course()->associate($course);
$question->user()->associate(auth()->user());
$question->save();
session()->flash('success', 'La pregunta ha sido enviada');
return redirect()->back();
}
示例6: addToCart
public function addToCart(Request $request)
{
$orders = $request->session()->get('orders');
if (isset($orders)) {
foreach ($orders as $course) {
if ($course->id == $request->course_id) {
return redirect()->back();
}
}
}
$course = Course::findOrFail($request->course_id);
$request->session()->push('orders', $course);
$request->session()->put('total', $this->totalPrice($request->session()->get('orders')));
return redirect()->back();
}
示例7: sendMail
public function sendMail($id)
{
$file = Data::findOrFail($id);
$pathToFile = $file->path;
Mail::raw(Input::get('body'), function ($message) use($pathToFile, $file) {
$message->to(Input::get('email'));
$message->subject(Input::get('subject'));
$message->attach($pathToFile, ['as' => $file->name, 'mime' => 'application/pdf']);
});
if ($file->courseId != null) {
$course = Course::findOrFail($file->courseId);
return Redirect::action('CoursesController@showParam', [$course->slug]);
}
if ($file->snippetId != null) {
$snippet = Snippet::findOrFail($file->snippetId);
return Redirect::action('CoursesController@show', [$snippet->slug]);
}
}
示例8: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$course = Course::findOrFail($id);
$questions = Question::where('course_id', '=', $course->id)->get();
return view('que.show', compact('course', 'questions'));
}
示例9: toggleLike
public function toggleLike($id)
{
$course = Course::findOrFail($id);
$course->toggleLike();
return Redirect::action('CoursesController@show', [$course->slug]);
}
示例10: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$course = Course::findOrFail($id);
if (\Auth::user()->role_id == 3) {
$professor = DB::table('professors')->join('users', 'professors.user_id', '=', 'users.id')->where('users.id', '=', \Auth::user()->id)->first();
return view('professor.edit_course', compact('course', 'professor'));
}
}
示例11: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
* @internal param ShowLessonRequest $request
*/
public function show($id)
{
$course = Course::findOrFail($id);
return view('courses.show')->with('course', $course)->with('title', $course->title);
}
示例12: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$course = Course::findOrFail($id);
$course->delete();
return redirect()->route('courses.index')->with('message', 'Item deleted successfully.');
}
示例13: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$course = Course::findOrFail($id);
$course->delete();
Session::flash('flash_message', 'Námskeiðinu hefur verið eytt');
return redirect()->route('dashboard.courses.index');
}
示例14: getDaysForCourse
/**
* Get the Days for A Course
* @param int $id
* @return App\Day
*/
public function getDaysForCourse($id)
{
$course = Course::findOrFail($id);
return $course->days;
}
示例15: getExamEdit
public function getExamEdit($id)
{
$course = Course::findOrFail($id);
$questions = $course->test()->first()->questions()->get();
return view('courses.test_edit', compact('questions'));
}