本文整理汇总了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();
});
}
示例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;
}
}
示例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));
}
示例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();
}
示例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;
}
示例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');
}
}
示例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"));
}
}
示例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]);
}
示例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;
}
示例10: delete
public function delete($id)
{
$event = Event::findOrFail($id);
$event->delete();
flash('Ви успішно видалили подію!');
return back();
}
示例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]);
}
示例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]);
}
示例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]);
}
}
示例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'));
}
示例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();
}