本文整理匯總了PHP中app\Event::query方法的典型用法代碼示例。如果您正苦於以下問題:PHP Event::query方法的具體用法?PHP Event::query怎麽用?PHP Event::query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Event
的用法示例。
在下文中一共展示了Event::query方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index(Request $request)
{
$this->validate($request, ['end_date' => 'date', 'start_date' => 'date', 'when' => 'in:past,future']);
$queryParameters = array_filter($request->only(['end_date', 'start_date', 'when']));
$events = Event::query();
if (array_key_exists('end_date', $queryParameters)) {
$events->where('end_date', $queryParameters['end_date']);
}
if (array_key_exists('start_date', $queryParameters)) {
$events->where('start_date', $queryParameters['start_date']);
}
if (array_key_exists('when', $queryParameters)) {
$now = Carbon::now();
switch ($queryParameters['when']) {
case 'past':
$events->where('end_date', '<', $now->toIso8601String());
break;
case 'future':
$events->where('start_date', '>', $now->toIso8601String());
break;
default:
abort(500);
}
}
return response()->json($events->paginate());
}
示例2: relatedEvents
public function relatedEvents()
{
$query = Event::query();
$this->relatedEventsAccount($query);
$this->relatedEventsEnvelope($query);
$this->relatedEventsRevenue($query);
$this->relatedEventsTransfer($query);
$this->relatedEventsIncome($query);
$this->relatedEventsOutcome($query);
return $query->orderBy('id', 'desc');
}