本文整理汇总了PHP中app\models\Event::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::where方法的具体用法?PHP Event::where怎么用?PHP Event::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Event
的用法示例。
在下文中一共展示了Event::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSearch
public function getSearch(Request $req)
{
if (!$_GET) {
return redirect()->action('SiteController@getIndex');
}
$query = $req->input('q', '');
$paid = $req->input('paid', 0);
$place = $req->input('place', '');
$all_types = EventType::toTransList();
$types = $req->input('types', []);
$ilikey = function (string $str) {
return strtr(" {$str} ", ' ', '%');
};
/** @var Builder $db_query */
$db_query = Event::where('hidden', 0);
if ($query) {
$db_query->where('title', 'ilike', $ilikey($query));
}
//FIXME: improve this text search
if ($paid) {
$db_query->where('free', $paid == -1);
}
if ($place) {
$db_query->where('location', 'ilike', $ilikey($place));
}
if ($types) {
$db_query->whereIn('event_type_id', $types);
}
$events = $db_query->get();
if (sizeof($events) == 1 && $query) {
return redirect()->to(act('event@details', $events[0]->slug));
}
return view('event.search', compact('query', 'paid', 'place', 'all_types', 'types', 'events'));
}
示例2: show
public function show($eventId)
{
$event = Event::where('user_id', '=', Auth::user()->id)->find($eventId);
if (!$event) {
return $this->respondNotFound('Event does not exist');
}
return $this->respond([$event->toArray()]);
}
示例3: eventRegistration
public function eventRegistration(Request $request, $slug)
{
$input = $request->all();
$refNo = uniqid();
$event = Event::where('slug', $slug)->first();
// REGISTER A USER
$user = $this->registerUser($input);
if (!$user) {
return redirect()->back()->withInput();
}
// REGISTER A USER TO EVENT
$this->registerUserToEvent($input, $user, $event);
// RECORD TRANSACTION
$this->recordTransaction($refNo, '7-Connect', $user, $event);
// Get payment uri
$paymentUrl = $this->processPayment($refNo, $slug);
return redirect()->to($paymentUrl);
}
示例4: indexWithStatus
/**
* Retrieve all Events of a certain status.
*
* @param Request $request
* @param string $status
* @return Collection|Response
*/
public function indexWithStatus(Request $request, $status)
{
try {
return Event::where('status', $status)->get();
} catch (Exception $e) {
return response()->error();
}
}
示例5: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$events = Event::where('organizer_id', $id)->get();
if ($events->count() == 0) {
$organizer = organizer::find($id);
$organizer->delete();
} else {
return back()->withErrors(['No se puede eliminar un organizador con eventos asociados']);
}
return redirect('promoter/organizers');
}
示例6: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
$events = Event::where('local_id', $id)->get();
if ($events->count() == 0) {
$local = Local::find($id);
$local->delete();
} else {
return back()->withErrors(['No se puede eliminar un local con eventos asociados']);
}
return redirect('admin/local');
}
示例7: getEventsBetweenDatesAndCardNumber
/**
* получаем все собыитя для $cardNumber и между двух дат
*
* @param $cardNumber
* @param Carbon $firstDayOfMonth
* @param Carbon $endDayOfMonth
* @return Collection
*/
private function getEventsBetweenDatesAndCardNumber($cardNumber, Carbon $firstDayOfMonth, Carbon $endDayOfMonth)
{
$events = Event::where('card_number', $cardNumber)->where([['created_at', '>=', $firstDayOfMonth->toDateTimeString()], ['created_at', '<=', $endDayOfMonth->toDateTimeString()]])->orderBy('created_at')->get();
return $events;
}
示例8: showSub
/**
* Display the specified resource.
*
* @param int $id, int $id2
* @return \Illuminate\Http\Response
*/
public function showSub($id, $id2)
{
$category = Category::findOrFail($id2);
$events = Event::where("cancelled", 0)->where('publication_date', '<', strtotime(Carbon::now()))->where('category_id', $id2)->whereHas('presentations', function ($query) {
$query->where('starts_at', '>', time());
})->paginate(8);
return view('external.subcategory', ["events" => $events, "category" => $category]);
}
示例9: getEventBySlug
public function getEventBySlug($slug)
{
$event = Event::where('slug', $slug)->first();
return $event;
}
示例10: actionExcel
public function actionExcel(Request $request)
{
$input = $request->all();
$flagBetweenDates = false;
$flagFilterAll = false;
//Condiciones que se pueden dar para filtrar la tabla
if (empty($input['name']) and empty($input['firstDate']) and empty($input['lastDate'])) {
$events = Event::all();
} else {
if ($input['name'] and empty($input['firstDate']) and empty($input['lastDate'])) {
$events = Event::where('name', 'LIKE', '%' . $input['name'] . '%')->get();
} elseif (empty($input['name']) and $input['firstDate'] and $input['lastDate']) {
$flagBetweenDates = true;
} elseif ($input['name'] and $input['firstDate'] and $input['lastDate']) {
$flagFilterAll = true;
}
}
$tickets = Ticket::all();
$eventInformation = [];
if ($flagBetweenDates) {
$fechaIni = strtotime($input['firstDate']);
$fechaFin = strtotime($input['lastDate']) + 86400;
//return $fechaFin;
$eventsDate = Presentation::whereBetween('starts_at', [$fechaIni, $fechaFin])->get();
foreach ($eventsDate as $eventDate) {
$event = Event::where('id', '=', $eventDate->event_id)->where('cancelled', '=', 0)->get();
if (count($event) != 0) {
$tickets = Ticket::where('presentation_id', '=', $eventDate->id)->get();
$onlineTickets = 0;
$presentialTicket = 0;
$subTotalOnline = 0;
$subTotalPresential = 0;
foreach ($tickets as $ticket) {
if ($ticket->cancelled != 1) {
if (empty($ticket->salesman_id)) {
$onlineTickets = $onlineTickets + $ticket->quantity;
$subTotalPresential = $subTotalPresential + $ticket->total_price;
} else {
$presentialTicket = $presentialTicket + $ticket->quantity;
$subTotalOnline = $subTotalOnline + $ticket->total_price;
}
}
}
array_push($eventInformation, array($event[0]->name, date("d/m/Y", $eventDate->starts_at), $onlineTickets, $subTotalPresential, $presentialTicket, $subTotalOnline, $subTotalPresential + $subTotalOnline));
}
}
} elseif ($flagFilterAll) {
$fechaIni = strtotime($input['firstDate']);
$fechaFin = strtotime($input['lastDate']) + 86400;
//return $fechaFin;
$eventsDate = Presentation::whereBetween('starts_at', [$fechaIni, $fechaFin])->get();
foreach ($eventsDate as $eventDate) {
//return $eventsDate;
$event = Event::where('name', 'LIKE', '%' . $input['name'] . '%')->where('cancelled', '=', 0)->where('id', '=', $eventDate->event_id)->get();
if ($event->count() != 0) {
$tickets = Ticket::where('presentation_id', '=', $eventDate->id)->get();
$onlineTickets = 0;
$presentialTicket = 0;
$subTotalOnline = 0;
$subTotalPresential = 0;
foreach ($tickets as $ticket) {
if ($ticket->cancelled != 1) {
if (empty($ticket->salesman_id)) {
$onlineTickets = $onlineTickets + $ticket->quantity;
$subTotalPresential = $subTotalPresential + $ticket->total_price;
} else {
$presentialTicket = $presentialTicket + $ticket->quantity;
$subTotalOnline = $subTotalOnline + $ticket->total_price;
}
}
}
array_push($eventInformation, array($event[0]->name, date("d/m/Y", $eventDate->starts_at), $onlineTickets, $subTotalPresential, $presentialTicket, $subTotalOnline, $subTotalPresential + $subTotalOnline));
}
}
} else {
foreach ($events as $event) {
// pueden ser muchos eventos. Necesito información para llenar la tabla
//filtro fechas si es necesario
$eventsDate = Presentation::where('event_id', '=', $event->id)->where('cancelled', '=', 0)->get();
foreach ($eventsDate as $eventDate) {
$tickets = Ticket::where('presentation_id', '=', $eventDate->id)->get();
$onlineTickets = 0;
$presentialTicket = 0;
$subTotalOnline = 0;
$subTotalPresential = 0;
foreach ($tickets as $ticket) {
if (empty($ticket->salesman_id)) {
$onlineTickets = $onlineTickets + $ticket->quantity;
$subTotalPresential = $subTotalPresential + $ticket->total_price;
} else {
$presentialTicket = $presentialTicket + $ticket->quantity;
$subTotalOnline = $subTotalOnline + $ticket->total_price;
}
}
array_push($eventInformation, array($event->name, date("d/m/Y", $eventDate->starts_at), $onlineTickets, $subTotalPresential, $presentialTicket, $subTotalOnline, $subTotalPresential + $subTotalOnline));
}
}
}
if ($input['type'] == 1) {
Excel::create('Reporte de ventas starkticket', function ($excel) use($eventInformation, $flagBetweenDates, $input) {
//.........这里部分代码省略.........
示例11: promoterHome
public function promoterHome()
{
$userId = Auth::user()->id;
$events = Event::where("promoter_id", $userId)->whereHas('presentations', function ($query) {
$query->where('starts_at', '>=', time());
})->paginate(10);
return view('internal.promoter.home', ["events" => $events]);
}
示例12: deleteEvent
public function deleteEvent(Request $request)
{
$validator = Validator::make($request->all(), ['event_id' => 'required|exists:events,id']);
if ($validator->fails()) {
return $validator->errors()->all();
}
$event = Event::where('id', '=', $request->event_id);
if ($event->count()) {
$event = $event->first();
} else {
return "invalid event";
}
$event = Event::where('id', '=', $request->event_id)->first()->delete();
return "success";
}
示例13: create
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function create()
{
$events = Event::where('promoter_id', Auth::user()->id)->get();
$accessPromotion = accessPromotion::orderBy('id')->get()->lists('description', 'id');
return view('internal.promoter.newPromotion', ['events' => $events, 'accessPromotion' => $accessPromotion]);
}
示例14: destroy
public function destroy(Request $request, $id)
{
$v = Event::find($id);
if ($v) {
// retrieve image detail prior to deletion
$images = DB::table('files')->join('event_files', 'files.id', '=', 'event_files.file_id')->where('event_files.event_id', $id)->get();
$res = Event::where("id", $id)->where('user_id', Auth::user()->id)->delete();
if ($res) {
// delete also the images from db and local storage
if (count($images) > 0) {
foreach ($images as $image) {
try {
$imgFile = File::find($image->file_id);
if ($imgFile) {
$imgFile->delete();
\Illuminate\Support\Facades\File::delete(MyHelper::getImageFromStorage($id, $imgFile->new_filename));
}
} catch (\Exception $e) {
Log::info($e->getMessage());
}
}
}
$request->session()->flash("notif", "Event successfully deleted");
return ['error' => false];
} else {
return ['error' => true, 'message' => 'Failed to delete event!'];
}
} else {
$request->session()->flash("notif", "Event not available!");
return ['error' => true];
}
}
示例15: getCalendar
public function getCalendar($year, $month)
{
$template = '
{table_open}<table class="calendar" border="0" cellpadding="0" cellspacing="0">{/table_open}
{heading_row_start}<tr class="calendar-header">{/heading_row_start}
{heading_previous_cell}<th><a href="{previous_url}"><<</a></th>{/heading_previous_cell}
{heading_title_cell}<th colspan="{colspan}">{heading}</th>{/heading_title_cell}
{heading_next_cell}<th><a href="{next_url}">>></a></th>{/heading_next_cell}
{heading_row_end}</tr>{/heading_row_end}
{week_row_start}<tr>{/week_row_start}
{week_day_cell}<td>{week_day}</td>{/week_day_cell}
{week_row_end}</tr>{/week_row_end}
{cal_row_start}<tr>{/cal_row_start}
{cal_cell_start}<td class="day">{/cal_cell_start}
{cal_cell_content}<div class="date">{day}</div><div>{content}</div>{/cal_cell_content}
{cal_cell_content_today}<div class="highlight date">{day}</div><div>{content}</div>{/cal_cell_content_today}
{cal_cell_no_content}{day}{/cal_cell_no_content}
{cal_cell_no_content_today}<div class="highlight">{day}</div>{/cal_cell_no_content_today}
{cal_cell_blank} {/cal_cell_blank}
{cal_cell_end}</td>{/cal_cell_end}
{cal_row_end}</tr>{/cal_row_end}
{table_close}</table>{/table_close}
';
$config = array('month_type' => 'long', 'day_type' => 'long', 'template' => $template);
Calendar::initialize($config);
$array = array();
foreach (range(1, 31) as $day) {
$dateN = date('N', strtotime($year . '-' . $month . '-' . str_pad($day, 2, 0, STR_PAD_LEFT)));
$meetings = Meeting::where('day_index', $dateN)->where('active', 1)->orderBy('meeting_time', 'ASC')->get();
$meetingString = '<h4>Meetings</h4>';
if (count($meetings)) {
foreach ($meetings as $meeting) {
$meetingString .= '<p>' . date('g:i a', strtotime($meeting->meeting_time)) . '<br/>' . $meeting->meeting . '</p>';
}
} else {
$meetingString = '<p>No meetings are scehduled for this day.</p>';
}
$eventString = '<h4>Events</h4>';
$events = Event::where('datetime', date('Y-m-d', strtotime($year . '-' . $month . '-' . str_pad($day, 2, 0, STR_PAD_LEFT))))->get();
if (count($events)) {
foreach ($events as $event) {
$eventString .= '<p>' . $event->description;
}
} else {
$eventString .= '<p>No events are scheduled for this day.</p>';
}
$array[$day] = $meetingString . $eventString;
}
return $array;
}