本文整理汇总了PHP中app\Course::published方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::published方法的具体用法?PHP Course::published怎么用?PHP Course::published使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Course
的用法示例。
在下文中一共展示了Course::published方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCoursesInCategory
public function getCoursesInCategory($slug)
{
$articles = Article::published()->orderBy('published_at', 'desc')->take(2)->get();
$category = Category::where('slug', $slug)->first();
$courses = Course::published()->where('category_id', $category->id)->get();
return view('courses.index', ['courses' => $courses, 'page_id' => $slug, 'category' => $category, 'latest_articles' => $articles]);
}
示例2: show
public function show($slug)
{
$page = Page::where('slug', $slug)->first();
$courses = Course::published()->hasCategory()->orderBy('created_at', 'desc')->take(4)->get();
$articles = Article::published()->orderBy('published_at', 'desc')->take(2)->get();
return view('pages.show', ['page' => $page, 'latest_courses' => $courses, 'latest_articles' => $articles]);
}
示例3: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
parent::boot($router);
$router->model('courses', 'App\\Course');
$router->bind('tags', function ($name) {
return Tag::where('name', $name)->firstOrFail();
});
$router->bind('courses', function ($id) {
return Course::published()->FindOrFail($id);
});
}
示例4: show
public function show(Course $course)
{
if (Enroll::where(['course_id' => $course->id, 'user_id' => Auth::user()->id])->ongoing()->exists() and $course->published()) {
$lecture = $course->lectures()->first();
$comments = $lecture->comments()->latest('created_at')->get();
return view('courses.course', compact('course', 'lecture', 'comments'));
}
return view('courses.show', compact('course'));
}
示例5: index
public function index()
{
$courses = Course::published()->hasCategory()->orderBy('created_at', 'desc')->take(4)->get();
$articles = Article::published()->orderBy('published_at', 'desc')->take(2)->get();
return view('home', ['latest_courses' => $courses, 'latest_articles' => $articles]);
}