本文整理匯總了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]);
}