本文整理汇总了PHP中app\models\Course::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::with方法的具体用法?PHP Course::with怎么用?PHP Course::with使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Course
的用法示例。
在下文中一共展示了Course::with方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$courses = Course::with('university')->get()->toArray();
if (count($courses) > 0) {
$message = 'Success';
return Response()->json(ResponseManager::getResult($courses, 10, $message));
} else {
$message = 'Error';
return Response()->json(ResponseManager::getError('', 10, $message));
}
}
示例2: index
/**
* @GET("/profile", as="profile.index")
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index()
{
$profile = $this->profile->profileWithUser();
$courses_raw = Course::with('currency')->get();
$courses = $courses_raw->filter(function ($value) {
return $value->id != 11;
});
if (!$profile->wallet) {
\Session::flash('message', 'Пожалуйста, укажите Elcoin кошелек и полностью заполните профиль, если у Вас нет кошелька,
зарегистрируйтесь в системе Elephant: https://elcoin.space');
}
return view('profile.profile', compact('profile', 'courses'));
}
示例3: getOverview
public function getOverview()
{
if (Auth::user()->hasRole(User::STUDENT_ROLE)) {
$courses = Course::with(['teacher', 'participants' => function ($query) {
$query->where('user_id', '=', Auth::id());
}])->orderBy('name')->paginate(10);
return view('courses.student.overview', ['courses' => $courses]);
} else {
$course = Auth::user()->course;
if ($course) {
$participants = $course->participants()->paginate(10);
} else {
$participants = [];
}
return view('courses.teacher.overview', ['participants' => $participants]);
}
}
示例4: get_elcoin
/**
* @POST("/get_currency_elcoin")
* @return string
*/
public function get_elcoin()
{
$course = Course::with('currency')->where('currency_id', 11)->first()->toArray();
return json_encode($course);
}
示例5: index
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index()
{
$courses = Course::with('currency')->get();
return view('admin.course.index', compact('courses'));
}