當前位置: 首頁>>代碼示例>>PHP>>正文


PHP models\Event類代碼示例

本文整理匯總了PHP中app\models\Event的典型用法代碼示例。如果您正苦於以下問題:PHP Event類的具體用法?PHP Event怎麽用?PHP Event使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Event類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testValidateCorrect

 public function testValidateCorrect()
 {
     $model = new Event(['type' => 'Type', 'name' => 'Name', 'event' => 'Event', 'title' => 'Title']);
     $this->specify('event wrong', function () use($model) {
         expect('model should not validate', $model->validate())->true();
     });
 }
開發者ID:vitalik74,項目名稱:event-app,代碼行數:7,代碼來源:EventTest.php

示例2: reschedule

 /**
  * Reschedule an existing event.
  *
  * @param  Event  $oldEvent
  * @param  array  $data
  * @return Event
  * @throws Exception
  */
 public function reschedule(Event $oldEvent, array $data)
 {
     try {
         DB::beginTransaction();
         // Recreate venue
         $newVenue = $oldEvent->venue->replicate();
         if (is_array($data['venue']) && count($data['venue'])) {
             $newVenue->fill($data['venue']);
         }
         $newVenue->save();
         // Recreate event
         $newEvent = $oldEvent->replicate();
         if (is_array($data['event']) && count($data['event'])) {
             $newEvent->fill($data['event']);
         }
         $newEvent->status_id = EventStatus::ACTIVE;
         $newEvent->venue_id = $newVenue->id;
         $newEvent->save();
         DB::commit();
         return $newEvent;
     } catch (\Exception $e) {
         DB::rollBack();
         throw $e;
     }
 }
開發者ID:slicvic,項目名稱:wgg,代碼行數:33,代碼來源:EventRepository.php

示例3: actionCreate

 public function actionCreate()
 {
     $model = new Event();
     if ($model->load(Yii::$app->request->post())) {
         $model->save();
         //var_dump($model->getErrors()); die;
     }
     return $this->render('create', array('model' => $model));
 }
開發者ID:rahaldr,項目名稱:hello-world,代碼行數:9,代碼來源:EventController.php

示例4: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $event = new Event();
     $event->event_name = "Test Event";
     $event->event_start_date = Carbon::createFromFormat('Y-m-d h:i A', '2016-05-21 12:00 PM')->toDateTimeString();
     $event->event_end_date = Carbon::createFromFormat('Y-m-d h:i A', '2016-05-21 3:30 PM')->toDateTimeString();
     $user = User::find(1);
     $event->user_id = $user->id;
     $event->save();
 }
開發者ID:rob-meh,項目名稱:weddinger,代碼行數:15,代碼來源:EventSeeder.php

示例5: reschedule

 /**
  * Determine if a given event can be rescheduled by the user.
  *
  * @param User $user
  * @param Event $event
  * @throws Exception
  */
 public function reschedule(User $user, Event $event)
 {
     if (!$event->isOrganizer($user)) {
         throw new AuthorizationException(trans('messages.event.not_your_own'));
     }
     if (!($event->isCanceled() || $event->hasPassed())) {
         throw new AuthorizationException(trans('messages.event.cannot_reschedule_active'));
     }
     return true;
 }
開發者ID:slicvic,項目名稱:wgg,代碼行數:17,代碼來源:EventPolicy.php

示例6: home

 public function home()
 {
     if ($this->auth->check()) {
         $events = new Event();
         $future = $events->future();
         $present = $events->present();
         $past = $events->past();
         return view('pages/dashboard', compact('future', 'present', 'past'));
     } else {
         return view('pages/home');
     }
 }
開發者ID:playatech,項目名稱:laravel-voldb,代碼行數:12,代碼來源:PageController.php

示例7: save

 /**
  * Save event data in the database
  *
  * @param array $data
  * @throws \Exception
  */
 public function save(array $data)
 {
     // Check event type
     if (!$this->hasValidEventType($data)) {
         throw new \Exception(\Yii::t("app", "Event has a invalid type: Should not be recorded."));
     }
     // Prepare the data for the model validation
     $eventData = ['Event' => $data];
     // New Event Model
     $eventModel = new Event();
     // Populate Event Model and Save (with validation)
     if (!$eventModel->load($eventData) || !$eventModel->save()) {
         throw new \Exception(Yii::t("app", "Error saving Event Model"));
     }
 }
開發者ID:ramialcheikh,項目名稱:quickforms,代碼行數:21,代碼來源:Storage.php

示例8: actionIndex

 public function actionIndex()
 {
     $query = Event::find();
     $pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]);
     $events = $query->orderBy('date')->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('index', ['events' => $events, 'pagination' => $pagination]);
 }
開發者ID:mts7,項目名稱:framework-compare,代碼行數:7,代碼來源:EventController.php

示例9: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Event::find();
     if (\Yii::$app->user->isGuest) {
         return null;
     }
     $user = \Yii::$app->user->identity;
     if (!$user->admin && count($user->organisations) == 0) {
         return null;
     } else {
         if (!$user->admin) {
             $organisations = $user->organisations;
             foreach ($organisations as $organisation) {
                 $query->orWhere(['owner_id' => $organisation->id]);
             }
         }
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'owner_id' => $this->owner_id, 'start_time' => $this->start_time, 'end_time' => $this->end_time]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'summary', $this->summary]);
     return $dataProvider;
 }
開發者ID:yodathedark,項目名稱:moltis-tickets,代碼行數:35,代碼來源:EventSearch.php

示例10: delete

 public function delete($id)
 {
     $event = Event::findOrFail($id);
     $event->delete();
     flash('Ви успішно видалили подію!');
     return back();
 }
開發者ID:Retsediv,項目名稱:edu,代碼行數:7,代碼來源:EventsController.php

示例11: actionUser

 public function actionUser($id = null)
 {
     $event = Event::getAll(Yii::$app->user->identity->id);
     $userinfo = Userinfo::getAll(Yii::$app->user->identity->id);
     $content = $this->renderPartial('userinfo', ['event' => $event, 'userinfo' => $userinfo]);
     return $this->render('user', ['content' => $content]);
 }
開發者ID:bderevyaga,項目名稱:IT-Revolution-2015,代碼行數:7,代碼來源:SiteController.php

示例12: index

 public function index()
 {
     $videoCount = Video::count();
     $memberCount = $this->userRepo->countMembers();
     $eventCount = Event::count();
     return view('admin.index', ['noOfVideos' => $videoCount, 'noOfMembers' => $memberCount, 'noOfEvents' => $eventCount]);
 }
開發者ID:arjayads,項目名稱:all-star,代碼行數:7,代碼來源:HomeController.php

示例13: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('events')->delete();
     for ($i = 1; $i <= 100; $i++) {
         Event::create(['title' => '我是活動 - ' . $i, 'content' => 'content ' . $i, 'begin_time' => \Carbon\Carbon::now(), 'end_time' => \Carbon\Carbon::now(), 'user_count' => rand(0, 1000), 'user_id' => 1]);
     }
 }
開發者ID:qloog,項目名稱:laravel5-backend,代碼行數:12,代碼來源:EventsTableSeeder.php

示例14: events

 /**
  * Search events.
  *
  * @param Request $request
  * @return \Illuminate\View\View
  */
 public function events(Request $request)
 {
     $ip = $request->ip();
     $ip = '73.85.49.134';
     $geolocation = $this->ipGeolocator->ipToGeolocation($ip);
     $perPage = 4;
     $defaultDistance = 25;
     $input = $request->only(['keyword', 'distance', 'lat', 'lng', 'city', 'type']);
     $input['distance'] = $input['distance'] ?: $defaultDistance;
     if (!$input['city'] && $geolocation) {
         $input['lat'] = $geolocation['lat'];
         $input['lng'] = $geolocation['lng'];
         $input['city'] = $geolocation['city'];
     }
     $events = Event::query()->filterActive()->filterUpcoming()->orderBySoonest();
     if ($input['keyword']) {
         $events->filterKeyword($input['keyword']);
     }
     if ($input['distance'] && is_numeric($input['distance'])) {
         $events->filterNearby($input['lat'], $input['lng'], $input['distance']);
     }
     if ($input['type']) {
         $events->filterTypes($input['type']);
     }
     $events = $events->paginate($perPage);
     $events->appends($input);
     return view('search.events.result', compact('events', 'input'));
 }
開發者ID:slicvic,項目名稱:wgg,代碼行數:34,代碼來源:SearchController.php

示例15: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // ---------------------------------------------------------------------
     // CONFERENCE 1
     // ---------------------------------------------------------------------
     $conference = ['name' => 'India Conference', 'description' => 'A conference in India.', 'start_date' => '2016-03-01', 'end_date' => '2016-03-31', 'address' => 'Sansad Marg, Connaught Place, New Delhi, Delhi 110001, India', 'city' => 'New Delhi', 'country' => 'India', 'capacity' => 1000, 'status' => 'approved'];
     $conference = Conference::create($conference);
     $event = ['name' => 'Opening Ceremony', 'description' => 'Welcome!', 'facilitator' => 'TBD', 'date' => '2016-05-01', 'start_time' => '09:00:00', 'end_time' => '10:00:00', 'address' => 'Sansad Marg, Connaught Place, New Delhi, Delhi 110001, India', 'city' => 'New Delhi', 'country' => 'India', 'capacity' => 1000, 'status' => 'approved'];
     $event = new Event($event);
     $event->conference()->associate($conference);
     $event->save();
     // ---------------------------------------------------------------------
     // CONFERENCE 2
     // ---------------------------------------------------------------------
     $conference = ['name' => 'Canada Conference', 'description' => 'A conference in Canada.', 'start_date' => '2016-05-11', 'end_date' => '2016-05-20', 'address' => '1055 Canada Pl, Vancouver, BC V6C 0C3, Canada', 'city' => 'Vancouver', 'country' => 'Canada', 'capacity' => 1000, 'status' => 'approved'];
     $conference = Conference::create($conference);
     $event = ['name' => 'Opening Ceremony', 'description' => 'Welcome!', 'facilitator' => 'TBD', 'date' => '2016-05-11', 'start_time' => '09:00:00', 'end_time' => '10:00:00', 'address' => '1055 Canada Pl, Vancouver, BC V6C 0C3, Canada', 'city' => 'Vancouver', 'country' => 'Canada', 'capacity' => 1000, 'status' => 'approved'];
     $event = new Event($event);
     $event->conference()->associate($conference);
     $event->save();
     // ---------------------------------------------------------------------
     // CONFERENCE 3
     // ---------------------------------------------------------------------
     $conference = ['name' => 'France Conference', 'description' => 'A conference in France.', 'start_date' => '2016-05-21', 'end_date' => '2016-05-30', 'address' => '17 Boulevard Saint-Jacques, Paris 75014, France', 'city' => 'Paris', 'country' => 'France', 'capacity' => 1000, 'status' => 'approved'];
     $conference = Conference::create($conference);
     $event = ['name' => 'Opening Ceremony', 'description' => 'Welcome!', 'facilitator' => 'TBD', 'date' => '2016-05-21', 'start_time' => '09:00:00', 'end_time' => '10:00:00', 'address' => '17 Boulevard Saint-Jacques, Paris 75014, France', 'city' => 'Paris', 'country' => 'France', 'capacity' => 1000, 'status' => 'approved'];
     $event = new Event($event);
     $event->conference()->associate($conference);
     $event->save();
     // ---------------------------------------------------------------------
     // CONFERENCE 4
     // ---------------------------------------------------------------------
     $conference = ['name' => 'CPSC 319 Final Demos', 'description' => 'Teams present their projects.', 'start_date' => '2016-03-31', 'end_date' => '2016-04-07', 'address' => 'Hugh Dempster Pavilion, 6245 Agronomy Road, Vancouver, BC V6T 1Z4', 'city' => 'Vancouver', 'country' => 'Canada', 'capacity' => 100, 'status' => 'approved'];
     $conference = Conference::create($conference);
     $event = ['name' => 'Project 2 Final Demos', 'description' => 'Teams 5 to 8 present their projects.', 'facilitator' => 'Dr Ahmed Awad', 'date' => '2016-03-31', 'start_time' => '12:30:00', 'end_time' => '14:00:00', 'address' => 'Hugh Dempster Pavilion, 6245 Agronomy Road, Vancouver, BC V6T 1Z4', 'city' => 'Vancouver', 'country' => 'Canada', 'capacity' => 100, 'status' => 'approved'];
     $event = new Event($event);
     $event->conference()->associate($conference);
     $event->save();
     $event = ['name' => 'Project 3 Final Demos', 'description' => 'Teams 9 to 12 present their projects.', 'facilitator' => 'Dr Ahmed Awad', 'date' => '2016-04-05', 'start_time' => '12:30:00', 'end_time' => '14:00:00', 'address' => 'Hugh Dempster Pavilion, 6245 Agronomy Road, Vancouver, BC V6T 1Z4', 'city' => 'Vancouver', 'country' => 'Canada', 'capacity' => 100, 'status' => 'pending'];
     $event = new Event($event);
     $event->conference()->associate($conference);
     $event->save();
     $event = ['name' => 'Project 1 Final Demos', 'description' => 'Teams 1 to 4 present their projects.', 'facilitator' => 'Dr Ahmed Awad', 'date' => '2016-04-07', 'start_time' => '12:30:00', 'end_time' => '14:00:00', 'address' => 'Hugh Dempster Pavilion, 6245 Agronomy Road, Vancouver, BC V6T 1Z4', 'city' => 'Vancouver', 'country' => 'Canada', 'capacity' => 100, 'status' => 'pending'];
     $event = new Event($event);
     $event->conference()->associate($conference);
     $event->save();
 }
開發者ID:vinlore,項目名稱:huddle,代碼行數:52,代碼來源:ConferencesAndEventsSeeder.php


注:本文中的app\models\Event類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。