本文整理汇总了PHP中app\Course::take方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::take方法的具体用法?PHP Course::take怎么用?PHP Course::take使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Course
的用法示例。
在下文中一共展示了Course::take方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Show the application dashboard to the user.
*
* @return Response
*/
public function index()
{
if ($this->adminAuth()) {
$categories = Category::take(10)->get();
$users = User::where('type', 'teacher')->take(5)->get();
$courses = Course::take(10)->get();
return view('adminHome', compact('courses', 'users', 'categories'));
} elseif ($this->teacherAuth()) {
$courses = Course::where('user_id', Auth::User()->id)->take(10)->get();
return view('teacherHome', compact('courses'));
} elseif ($this->studentAuth()) {
$courseStudents = CourseStudent::where('user_id', Auth::User()->id)->take(10)->get();
return view('studentHome', compact('courseStudents'));
}
//return view('home');
}
示例2: courses
public function courses($page = 1)
{
$this->data['current_page'] = $page;
$limit = 8;
$offset = ($page - 1) * $limit;
$this->data['courses'] = Course::take($limit)->skip($offset)->get();
$total = Course::all()->count();
$this->data['total'] = $total;
$num_pages = ceil($total / $limit);
$this->data['num_pages'] = $num_pages;
$landing = Landing::all();
$this->data['landing'] = $landing;
$this->data['current_tab'] = 7;
return view('manage.courses', $this->data);
}