当前位置: 首页>>代码示例>>PHP>>正文


PHP Event::findOrFail方法代码示例

本文整理汇总了PHP中app\Event::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::findOrFail方法的具体用法?PHP Event::findOrFail怎么用?PHP Event::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Event的用法示例。


在下文中一共展示了Event::findOrFail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 /**
  * update an user
  * @param $id
  * @param array $data
  * @return mixed
  */
 public function update($id, array $data)
 {
     $user = $this->model->findOrFail($id)->update($data);
     if (isset($data['profile'])) {
         $this->model->findOrFail($id)->profile()->update($data['profile']);
     }
     return $user;
 }
开发者ID:iris-it,项目名称:irispass-webapp-laravel,代码行数:14,代码来源:UserRepository.php

示例2: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $event = Event::findOrFail($id);
     $event->delete();
     \Flash::success('Agenda evenement verwijderd');
     return redirect('admin/events');
 }
开发者ID:svuvis,项目名称:oshusite,代码行数:13,代码来源:EventsController.php

示例3: update

 public function update($id, EventRequest $request)
 {
     $event = Event::findOrFail($id);
     $event->update($request->all());
     flash()->message('Successfully updated event: ' . $event->name, 'success');
     return redirect()->route('admin.events.edit', $event->id);
 }
开发者ID:jovvybersamin,项目名称:laravel-edronscateringservices,代码行数:7,代码来源:EventController.php

示例4: userEntries

 /**
  * Page for the users' entries.
  * @return mixed
  */
 public function userEntries()
 {
     $user = Auth::user();
     $event_ids = $user->entries()->pluck('event_id')->unique();
     $eventsarray = array();
     foreach ($event_ids as $event_id) {
         $eventsarray[] = Event::findOrFail($event_id);
     }
     $events = collect($eventsarray);
     return view('user.entries')->with(['user' => $user, 'events' => $events]);
 }
开发者ID:rachelglover,项目名称:entries,代码行数:15,代码来源:PagesController.php

示例5: destroy

 /**
  * Delete a detail
  * @param Request $request
  * @param $id
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function destroy(Request $request, $id)
 {
     $event = Event::find($request->input('event'));
     $detail = Detail::find($id);
     if ($detail && $event->user_id == $request->user()->id) {
         $detail->delete();
         //Flash a message to the user
         \Flash::success('Detail deleted');
     } else {
         //Flash a message to the user
         \Flash::danger('Sorry, permission denied');
     }
     $event = Event::findOrFail($request->input('event'));
     //Redirect back to the admin page
     return redirect(action('EventsController@admin', $event->slug));
 }
开发者ID:rachelglover,项目名称:entries,代码行数:22,代码来源:DetailController.php

示例6: buyTicket

 public function buyTicket()
 {
     if (\Request::ajax()) {
         $event_id = (int) \Request::get('event_id');
         $event = Event::findOrFail($event_id);
         $ticket = [];
         $ticket['price'] = round($event->price * \Request::get('quantity'), 2);
         $ticket['raw_price'] = round($event->price * \Request::get('quantity'), 2);
         $ticket['quantity'] = \Request::get('quantity');
         if (\Request::get('promocode') === $event->promocode) {
             $ticket['price'] = round($ticket['price'] - $event->discount, 2);
         }
         $user = \Request::user();
         $ticket = $user->tickets()->create($ticket);
         $ticket->event()->associate($event)->save();
         return \Response::json(['status' => 'success']);
     }
     return \Response::json(['status' => 'error'], 400);
 }
开发者ID:borovaka,项目名称:events,代码行数:19,代码来源:TicketsFrontController.php

示例7: register

 public function register($id)
 {
     $event = Event::findOrFail($id);
     if ($event->flash_message) {
         $_SESSION['ALERT'] = alert("Event Notice!", $event->flash_message, "warning");
     }
     $score = new Score();
     $score->event_id = $event->id;
     $score->player_id = Auth::user()->id;
     $score->save();
     if (!Auth::user()->no_email) {
         $subject = 'Event Registration';
         Mail::send('emails.registered', compact('subject', 'event'), function ($m) use($subject) {
             $m->to(Auth::user()->email)->subject($subject);
         });
     }
     return redirect('/');
 }
开发者ID:MadeByGlutard,项目名称:GreenMountainGaming.com,代码行数:18,代码来源:EventsController.php

示例8: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     //        $router->model('user' , 'App\User');
     $router->bind('user', function ($value) {
         return User::with('roles')->findOrFail($value);
     });
     /**
      * created by dara on 6/9/2015
      * add binding for admin wild card
      */
     $router->bind('admin', function ($value) {
         return User::with('roles')->findOrFail($value);
     });
     /**
      * Created by Emad Mirzaie on 09/09/2015.
      * province wild cart
      */
     $router->model('province', 'App\\Province');
     $router->model('city', 'App\\Province');
     $router->model('university', 'App\\University');
     $router->model('article', 'App\\Article');
     $router->model('post', 'App\\Post');
     $router->model('category', 'App\\Category');
     $router->model('sub_category', 'App\\Category');
     $router->model('skill', 'App\\Skill');
     $router->model('profile', 'App\\User');
     $router->model('comment', 'App\\Comment');
     $router->model('poll', 'App\\Poll');
     $router->model('questionnaire', 'App\\Questionnaire');
     $router->model('coupon_user', 'App\\CouponUser');
     $router->model('showcase', 'App\\Showcase');
     $router->model('sticky', 'App\\Sticky');
     /**
      * Created By Dara on 22/10/2015
      */
     //        $router->bind('offer',function($value){
     //            return Offer::findOrFail($value);
     //        });
     $router->bind('service', function ($value) {
         return CouponGallery::findOrFail($value);
     });
     $router->bind('coupon', function ($value) {
         return Coupon::findOrFail($value);
     });
     $router->bind('group', function ($value) {
         return Group::findOrFail($value);
     });
     $router->bind('problem', function ($value) {
         return Problem::findOrFail($value);
     });
     $router->model('offer', 'App\\Offer');
     $router->model('shop', 'App\\Shop');
     $router->model('product', 'App\\Product');
     $router->bind('event', function ($value) {
         return Event::findOrFail($value);
     });
     $router->bind('settle', function ($value) {
         return Settle::findOrFail($value);
     });
     $router->bind('report', function ($value) {
         return Report::findOrFail($value);
     });
     $router->bind('corporation', function ($value) {
         return Corporation::findOrFail($value);
     });
     /**
      * Created By Dara on 25/12/2015
      */
     $router->bind('announcement', function ($value) {
         return Announcement::findOrFail($value);
     });
     $router->bind('storage', function ($value) {
         return Storage::findOrFail($value);
     });
     $router->bind('role', function ($value) {
         return Role::findOrFail($value);
     });
 }
开发者ID:emadmrz,项目名称:Hawk,代码行数:85,代码来源:RouteServiceProvider.php

示例9: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param EventRequest $request
  * @param $eventId
  * @return \Illuminate\Http\JsonResponse
  */
 public function destroy(EventRequest $request, $eventId)
 {
     Event::findOrFail($eventId)->delete();
     return $this->response->noContent();
 }
开发者ID:leloulight,项目名称:powerjump,代码行数:12,代码来源:EventsController.php

示例10: toggle

 /**
  * Toggle the online
  * @param $id
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function toggle($id)
 {
     //Get the event by ID
     $item = Event::findOrFail($id);
     //Toggle the online property
     $item->online = !$item->online;
     $item->update();
     return redirect('event');
 }
开发者ID:NikoNick,项目名称:EventsBerry,代码行数:14,代码来源:EventController.php

示例11: destroy

 public function destroy($id)
 {
     $event = Event::findOrFail($id);
     $event->delete();
     return Response::json([], 200);
 }
开发者ID:VincentVanWijk,项目名称:artotheek5,代码行数:6,代码来源:EventController.php

示例12: store

 /**
  * Creates a ticket for the event for the logged-in user, or if the user
  * already has a ticket, return theirs.
  *
  * @param  Integer 	$eventId 	ID of the event for the ticket.
  * @return View 		        Ticket View
  */
 public function store()
 {
     $data = Request::only(["event_id", "stripeToken"]);
     try {
         $event = Event::findOrFail($data["event_id"]);
     } catch (ModelNotFoundException $e) {
         return Redirect::back()->withErrors(['message' => $this->errorMessages['event_not_found']]);
     }
     $user = Auth::user();
     if (Ticket::where('event_id', $event->id)->where('user_id', $user->id)->get()->toArray()) {
         return Redirect::back()->withErrors(["message" => $this->errorMessages['ticket_exists']]);
     }
     if ($event->price > 0) {
         // If the ticket ain't free you're going to have to pay for it.
         // Let's Stripe.
         Stripe::setApiKey(env('STRIPE_SECRET'));
         try {
             // Create a reference for a Customer relating to the Stripe token we received
             $customer = Customer::create(["email" => $user->email, "card" => $data["stripeToken"]]);
             // Now, charge that customer for the ticket as expected.
             $charge = Charge::create(["customer" => $customer->id, "amount" => $event->price * 100, "currency" => "eur"]);
         } catch (Error\Card $e) {
             return Redirect::back()->withErrors(["message" => $this->errorMessages['card_declined']]);
         } catch (Error\RateLimit $e) {
             return \Redirect::back()->withErrors(["message" => $this->errorMessages['server_error']]);
         } catch (Error\InvalidRequest $e) {
             dd($e);
             return Redirect::back()->withErrors(["message" => $this->errorMessages['dev_mistake']]);
         } catch (Error\Authentication $e) {
             return Redirect::back()->withErrors(["message" => $this->errorMessages['dev_mistake_auth']]);
         } catch (Error\ApiConnection $e) {
             return Redirect::back()->withErrors(["message" => $this->errorMessages['network_error']]);
         } catch (Error\Base $e) {
             // I actually don't know what this error means
             // or what it does, so probably panic
             return Redirect::back()->withErrors(["message" => $this->errorMessages['something_wrong']]);
         }
         $ticket = Ticket::create(["user_id" => $user->id, "event_id" => $event->id, "price" => $event->price, "used" => false, "printed" => false, "charge_id" => $charge->id]);
     } else {
         $ticket = Ticket::create(["user_id" => $user->id, "event_id" => $event->id, "price" => $event->price, "used" => false, "printed" => false, "charge_id" => null]);
     }
     MailController::sendTicket($ticket);
     return Redirect::back()->with('message', "You've got a ticket! Find your details and print it out here.");
 }
开发者ID:TheJokersThief,项目名称:Eve,代码行数:51,代码来源:TicketController.php

示例13: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function destroy($id)
 {
     /** @var Event $event */
     $event = Event::findOrFail($id);
     if ($event->date < Carbon::now()) {
         Flash::error('Este evento ya ocurrió, no puede ser eliminado.');
         return Redirect::route('events.show', $id);
     }
     if ($this->destroyPrototype($event, 'delete', 'Evento', 'Involucrados')) {
         return Redirect::route('events.index');
     }
     return Redirect::route('events.show', $id);
 }
开发者ID:slayerfat,项目名称:certificador,代码行数:19,代码来源:EventsController.php

示例14: update

 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['description' => 'string', 'end_date' => 'date', 'featured' => 'boolean', 'group' => 'exists:groups,id', 'image' => 'string', 'location' => 'string', 'name' => 'string', 'recurrence' => 'string', 'short_description' => 'string', 'short_name' => 'string', 'start_date' => 'date']);
     try {
         $event = Event::findOrFail($id);
         $event->description = $request->input('description', $event->description);
         $event->end_date = $request->input('end_date', $event->end_date);
         $event->featured = $request->input('featured', $event->featured);
         $event->group_id = $request->input('group', $event->group_id);
         $event->image = $request->input('image', $event->image);
         $event->location = $request->input('location', $event->location);
         $event->name = $request->input('name', $event->name);
         $event->recurrence = $request->input('recurrence', $event->recurrence);
         $event->short_description = $request->input('short_description', $event->short_description);
         $event->short_name = $request->input('short_name', $event->short_name);
         $event->start_date = $request->input('start_date', $event->start_date);
         $event->save();
         return new JsonResponse($event, Response::HTTP_CREATED);
     } catch (ModelNotFoundException $e) {
         return new JsonResponse(['error' => 'not found'], Response::HTTP_NOT_FOUND);
     }
 }
开发者ID:rit-sse,项目名称:api,代码行数:29,代码来源:EventController.php

示例15: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function update($id, Request $request)
 {
     $event = Event::findOrFail($id);
     $event->title = $request->title;
     $event->intro = $request->intro;
     $event->description = $request->description;
     $event->vortex_url = $request->vortex_url;
     $event->facebook_id = $request->facebook_id;
     $event->start_date = new Carbon($request->start_date);
     $event->location = $request->location;
     if (!$request->youtube_playlist_id) {
         $event->youtube_playlist_id = null;
     } else {
         $youtubePlaylist = YoutubePlaylist::find($request->youtube_playlist_id);
         $event->youtube_playlist_id = $youtubePlaylist->id;
     }
     $event->save();
     // Organizers: TODO
     $p1 = $event->presentations[0];
     $p1->start_time = $request->p1_start_time;
     $p1->end_time = $request->p1_end_time;
     // ...
     $p1->save();
     if ($request->has('p1_person1')) {
         // TODO
     }
     if ($request->has('p1_youtube_id')) {
         $recording = Recording::where('presentation_id', '=', $p1->id)->first();
         if (!is_null($recording)) {
             if ($recording->id != $request->p1_youtube_id) {
                 $recording->presentation_id = null;
             }
         }
         $recording = Recording::where('youtube_id', '=', $request->p1_youtube_id)->first();
         if (is_null($recording)) {
             die("TODO: Video not found, redirect back with meaningful error message");
         }
         $recording->presentation_id = $p1->id;
         $recording->save();
     }
     return redirect()->action('EventsController@show', $event->id)->with('status', 'Arrangementet ble oppdatert.');
 }
开发者ID:scriptotek,项目名称:bibsprut,代码行数:49,代码来源:EventsController.php


注:本文中的app\Event::findOrFail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。