本文整理汇总了PHP中app\Event::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::where方法的具体用法?PHP Event::where怎么用?PHP Event::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Event
的用法示例。
在下文中一共展示了Event::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
if (Auth::guest()) {
return view('pages.home');
}
//Check to make sure gender and names are populated
$user = Auth::user();
$fields = ['first_name' => $user->first_name, 'last_name' => $user->last_name, 'gender' => $user->gender];
$validation = Validator::make($fields, User::$baseRules);
if (!$validation->passes()) {
return redirect('user/name-and-gender');
}
//Check to make sure user has choson categories
if (!$this->categoryAccount->where('user_id', $user->id)->first()) {
return redirect('user/categories');
}
$chosenCategories = $this->categoryAccount->where('user_id', Auth::user()->id)->orderByRaw('RAND()')->get();
//Get one random task for the "one for the road"
$oneForTheRoad = array();
foreach ($chosenCategories as $category) {
$events = $this->event->where('type', $category->category_id)->orderByRaw('RAND()')->get();
foreach ($events as $event) {
if (!$this->eventUser->where('event_id', $event->id)->where('user_id', Auth::user()->id)->first() && !$this->eventUser->where('user_id', Auth::user()->id)->where('created_at', '<=', date('Y-m-d 24:00:00'))->where('created_at', '>=', date('Y-m-d 00:00:00'))->where('complete', 1)->first()) {
array_push($oneForTheRoad, ['id' => $event->id, 'name' => $event->name, 'description' => $event->description, 'class' => 'active']);
} else {
array_push($oneForTheRoad, ['id' => '0', 'name' => 'None for today!', 'description' => 'One for the road has completed', 'class' => 'inactive']);
}
}
}
$category = $this->category;
return view('pages.dashboard', compact('category', 'chosenCategories', 'oneForTheRoad'));
}
示例2: Home
public function Home()
{
$flash = Event::where('start_date', '<=', new \Datetime())->where('end_date', '>=', new \Datetime())->orderBy('id', 'desc')->take(1)->get()->first();
$articles = Article::where('id', '!=', isset($flash) ? $flash->article->id : 0)->orderBy('publish_at', 'desc')->orderBy('id', 'desc')->take(5)->get();
$ffttNews = FFTTNew::orderBy('date', 'desc')->take(3)->get();
return view('front.home', array('articles' => $articles, 'NewsFlash' => $flash, 'ffttNews' => $ffttNews));
}
示例3: delete
public function delete($id)
{
\App\Event::where('id', $id)->delete();
\App\EventMedia::where('eventID', $id)->delete();
\App\EventTag::where('eventID', $id)->delete();
return redirect('/');
}
示例4: getCalendar
public function getCalendar()
{
$eventos = Event::select('titulo_evento')->where('user_id', '=', Auth::user()->id)->take(4)->get();
//$datos['cTrabajo']= \DB::table('trabajo')->count();
$array = Event::where('user_id', '=', Auth::user()->id)->get();
return view('Calendar/calendar', compact('array', 'datos', 'eventos'));
}
示例5: postTask
function postTask(Request $request)
{
$task = $request->all();
Task::create($task);
$comm = Committee::where('id', $task['comm_id'])->first();
$evnt = Event::where('id', $comm['event_id'])->first();
//UPDATING WEIGHT OF COMMITTEE AND EVENT
$comm->increment('weight', $task['weight']);
$evnt->increment('weight', $task['weight']);
//UPDATING PROGRESS OF COMMITTEE
$progress = 0;
$tasks = Task::where('comm_id', $comm->id)->get();
foreach ($tasks as $task1) {
$progress += $task1->weight * $task1->progress;
}
$progress = $progress / $comm->weight;
$comm->progress = $progress;
$comm->save();
//UPDATING PROGRESS OF EVENT
$progress2 = 0;
$committees = Committee::all();
foreach ($committees as $committee) {
if ($committee->event_id == $evnt->id) {
$progress2 += $committee->weight * $committee->progress;
}
}
$progress2 = $progress2 / $evnt->weight;
$evnt->progress = $progress2;
$evnt->save();
return redirect('profile');
}
示例6: down
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$city = City::findByIATA('nyc')->first();
$event = Event::where('city_id', '=', $city->id);
$city->delete();
$event->delete();
}
示例7: index
/**
* Render front page view
* @return VIEW welcome
*/
public function index()
{
$all_events = Event::where('time', '>', date('Y-m-d H:i:s'))->orderBy(DB::raw('RAND()'));
$first_six = $all_events->take(6)->get();
$next_six = $all_events->skip(6)->take(6)->get();
return View::make('welcome')->with('first_six', $first_six)->with('next_six', $next_six);
}
示例8: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$cities = City::all();
// Grab all the cities and then do a for each.
// run this for each of them.
foreach ($cities as $city) {
$events = Event::where('city_id', '=', $city->id)->where('time_end', '>=', date('Y-m-d H:i:s'))->where('time_end', '<=', date('Y-m-d H:i:s', strtotime('+2 weeks')))->orderBy('time_start', 'asc')->get();
if (!count($events)) {
$this->comment('No events found for ' . $city->name . '. Mailer not sent.');
continue;
}
$categories = Category::orderBy('title', 'asc')->get();
if ($this->option('email')) {
$subscriber = new Subscriber();
$subscriber->name = 'Test User';
$subscriber->email = $this->option('email');
$subscribers = [$subscriber];
$this->comment('Sent test email to ' . $this->option('email'));
} else {
$subscribers = Subscriber::where('city_id', '=', $city->id)->get();
}
$count = 0;
foreach ($subscribers as $subscriber) {
Mail::send('emails.subscribers.mailer', ['subscriber' => $subscriber, 'events' => $events, 'categories' => $categories, 'city' => $city], function ($m) use($subscriber, $city) {
$m->from('messages@madebyfieldwork.com', 'See+Do')->to($subscriber->email, $subscriber->name)->subject('Weekly Round-Up of Things to See+Do in ' . $city->name)->getHeaders()->addTextHeader('X-MC-Subaccount', 'see-do');
});
$count++;
}
$this->comment('Sent to ' . $count . ' email addresses in ' . $city->name . '.');
$count = 0;
}
}
示例9: handle
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
// Same time next week! :D
$job = (new \App\Jobs\WeeklyMail())->delay(604800);
$this->dispatch($job);
// We'll just want to double-check our Facebook events still exist
// before we email people about them...
FacebookSession::setDefaultApplication(getenv('FB_ID'), getenv('FB_SECRET'));
$session = FacebookSession::newAppSession();
try {
$session->validate();
} catch (FacebookRequestException $ex) {
// Session not valid, Graph API returned an exception with the reason.
dd($ex);
} catch (\Exception $ex) {
// Graph API returned info, but it may mismatch the current app or have expired.
dd($ex);
}
$all_events = Event::where('time', '>', date('Y-m-d H:i:s'))->where('time', '<', date('Y-m-d H:i:s', time() + 604800))->get();
foreach ($all_events as $event) {
$request = new FacebookRequest($session, 'GET', "/" . $event->facebook_id);
try {
$response = $request->execute();
} catch (\Exception $ex) {
// Facebook Exception looking up event; probably deleted, should mirror here.
$event->delete();
}
}
foreach (User::where('unsubscribed_email', 'no') as $user) {
$this->dispatch(new SendEmail($user));
}
}
示例10: editTimeline
/**
* Edit timeline /
*/
public function editTimeline($timeline_id, Request $request)
{
$timeline = \App\Timeline::where('id', '=', $timeline_id)->first();
$timeline_events = $timeline->event()->orderBy('start_date')->get();
if ($request->input('showForm') == 'true') {
return view('timelines.editTimeline')->with('showForm', 'true')->with('timeline', $timeline)->with('timeline_events', $timeline_events);
} else {
// Else submit form
// Validate the request data
$this->validate($request, ['name' => 'required']);
$user = \Auth::user();
$timeline->name = $request->input('name');
$timeline->description = $request->input('description');
$timeline->last_modified_by = $user->id;
$timeline->save();
// Delete events
for ($e = 0; $e < count($timeline_events); $e++) {
if ($request->input('delete_event' . $e) == 'true') {
\DB::table('character_event')->where('event_id', '=', $timeline_events[$e]->id)->delete();
\DB::table('event_location')->where('event_id', '=', $timeline_events[$e]->id)->delete();
$event = \App\Event::where('id', '=', $timeline_events[$e]->id)->first();
if ($event) {
$event->delete();
}
}
}
// Return success message
return view('timelines.editTimeline')->with('showForm', 'false')->with('timeline', $timeline);
}
}
示例11: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($type, $id)
{
if ($id == 'video') {
$events = Video::all();
return view('video.show', compact('events'));
} elseif ($id == 'staff') {
$events = Staff::all();
return view('staff.show', compact('events'));
} elseif ($id == 'gallery') {
$events = Image::all();
return view('gallery.show', compact('events'));
} else {
$event = Event::where('slug', $id)->where('type', $type)->first();
$location = Location::where('event_id', $event->id)->first();
$slider = EventImage::where('event_id', $event->id)->orderBy(\DB::raw('RAND()'))->take(4)->get();
$gallery = EventImage::where('event_id', $event->id)->first();
if ($event->type == $type) {
if ($event->status == 1) {
return view($type . '.show', compact('event', 'location', 'slider', 'gallery'));
} else {
return redirect('/' . $type . '/');
}
}
}
}
示例12: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$events = Event::where('user_id', $user_id)->get();
$jobs = Job::where('user_id', $user_id)->get();
// return view('members.dashboardpage', ['user' => $user, 'events' => $events, 'jobs' => $jobs]);
return view('public.frontpage', ['user' => $user, 'events' => $events, 'jobs' => $jobs]);
}
示例13: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$slug = $request->route('slug');
$event = Event::where(['slug' => $slug])->first();
//dd(\Auth::user()->role);
$role = \Auth::user()->role;
return $next($request);
}
示例14: viewSingle
public function viewSingle($id)
{
if (!Event::where('id', $id)->exists()) {
return redirect('/');
}
$event = Event::where('id', $id)->first();
return view('single', compact('event', 'title', 'events'));
}
示例15: tearDown
protected function tearDown()
{
PollResponse::where('pid', $this->pollOption->oid)->delete();
PollOption::where('oid', $this->pollOption->oid)->delete();
Poll::where('pid', $this->poll->pid)->delete();
Event::where('eid', $this->event->eid)->delete();
User::where('uid', $this->user->uid)->delete();
}