本文整理汇总了PHP中app\models\Course::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::where方法的具体用法?PHP Course::where怎么用?PHP Course::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Course
的用法示例。
在下文中一共展示了Course::where方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* @POST("/purchase", as="purchase.store")
* @param Purchase $purchase
* @param Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(Purchase $purchase, Request $request)
{
$data = $request->all();
if ((int) $data['amount'] <= 0) {
return redirect()->route('profile.index')->with('message', 'Некорректная сумма вклада!');
}
$type1 = TypePurchase::where('id', 1)->first();
$type2 = TypePurchase::where('id', 2)->first();
$type3 = TypePurchase::where('id', 3)->first();
$user = User::where('id', $request->input('user_id'))->first();
$course = Course::where('currency_id', $request->input('currency_id'))->first();
$data['course'] = $course->course_purchase;
if ($request->input('status_trust') === 'true') {
$data['status_trust'] = 1;
$purchase->fill($data);
$purchase->type()->associate($type2);
$purchase->user()->associate($user);
$purchase->course()->associate($course);
$purchase->save();
} elseif (!$request->input('total')) {
$data['total'] = $request->input('amount');
$purchase->fill($data);
$purchase->type()->associate($type3);
$purchase->user()->associate($user);
$purchase->course()->associate($course);
$purchase->save();
} else {
$purchase->fill($data);
$purchase->type()->associate($type1);
$purchase->user()->associate($user);
$purchase->course()->associate($course);
$purchase->save();
}
return redirect()->route('profile.index')->with('message', 'Заявка сделана! Свои оперции Вы можете
посмотреть в разделе "Мои операции"');
}
示例2: universityCourses
public function universityCourses($uni_id)
{
$courses = Course::where('university_id', $uni_id)->get()->toArray();
if ($courses) {
$message = 'Success';
return Response()->json(ResponseManager::getResult($courses, 10, $message));
} else {
$message = 'No Course added';
return Response()->json(ResponseManager::getError('', 10, $message));
}
}
示例3: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$delete = Course::where('id', $id)->delete();
if ($delete) {
$message = 'Detele successfully';
return Response()->json(ResponseManager::getResult($delete, 10, $message));
} else {
$message = 'Error while deleting';
return Response()->json(ResponseManager::getError('', 10, $message));
}
}
示例4: search
/**
* Search in courses.
*
* @param string $search
* @return Response
*/
public function search($id, $search)
{
$courses = Course::where('name', 'like', '%' . $search . '%')->where('college_id', $id)->take(6)->get();
return response()->json($courses);
}
示例5: viewCourseByLecturer
/**
* Show all course only taught by this lecturer on current semester
* @return $this
*/
public function viewCourseByLecturer()
{
//get current user
$user = Auth::user();
//get the mapping for lecturer
$kode_dosen = $user->lecturer->Kode_Dosen;
$id_semester = Kalender::getRunningSemester()->id;
$courses = Course::where('Kode_Dosen', $kode_dosen)->where('id_semester', $id_semester)->get();
return view('lecturers.showcourse')->with('Courses', $courses);
}
示例6: checkSectionId
protected function checkSectionId($validator)
{
$seksi = $validator->getData()['kode_seksi'];
$id_semester = Kalender::getRunningSemester()->id;
$instance = Course::where('seksi', $seksi)->where('id_semester', $id_semester)->get();
if (count($instance) == 0) {
return true;
}
return false;
//the precondition for being add, section id must not exist for current user or has been registered
}