本文整理汇总了PHP中app\models\Event::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::find方法的具体用法?PHP Event::find怎么用?PHP Event::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Event
的用法示例。
在下文中一共展示了Event::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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]);
}
示例2: actionOtchet
public function actionOtchet()
{
$this->layout = false;
$poisk1 = Yii::$app->request->post('from_date');
$poisk2 = Yii::$app->request->post('to_date');
return $this->render('otchet', ['model' => Event::find()->where(['between', 'date_event', $poisk1, $poisk2])->orderBy('date_event, time_event')->all(), 'poisk1' => $poisk1, 'poisk2' => $poisk2]);
}
示例3: 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;
}
示例4: actionIndex
/**
* Lists all Event models.
* @return mixed
*/
public function actionIndex($id = null)
{
//Check user level & existence of $id
$id = Yii::$app->user->identity->level == 0 && $id != null ? $id : Yii::$app->user->id;
//$searchModel = new EventSearch();
//$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', ['events' => Event::find()->where('FIND_IN_SET(' . $id . ', shared_with)')->orWhere('user_id=' . $id)->all()]);
}
示例5: actionEvents_item
/**
* Выводит событие
*
* @param int $id идентификатор события
*
* @return string
* @throws \cs\web\Exception
*/
public function actionEvents_item($id)
{
$item = Event::find($id);
if (is_null($item)) {
throw new Exception('Событие не найдено');
}
return $this->render(['item' => $item]);
}
示例6: getRoom
public function getRoom($eventId)
{
$event = Event::find($eventId);
$room = $event->room;
if (!$room) {
return $this->respondNotFound('Room Not Found!');
}
return $this->respond([$room->toArray()]);
}
示例7: eventPost
public function eventPost($id)
{
//
$event = Event::find($id);
$posts = $event->posts;
$response = new \stdClass();
$response->success = true;
$response->total = count($posts);
$response->data = $posts;
return response()->json($response);
}
示例8: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//dd(Input::get('data'));
$data = Input::get('data');
foreach ($data as $key => $value) {
if (Event::find($value['id']) != null) {
Event::find($value['id'])->update(['title' => $value['title'], 'start' => $value['start'], 'end' => $value['end']]);
} else {
Event::create(array('title' => $value['title'], 'start' => $value['start'], 'end' => $value['end']));
}
}
}
示例9: actionIndex
/**
* Lists all Event models.
* @return mixed
*/
public function actionIndex()
{
$events = Event::find()->all();
$tasks = [];
foreach ($events as $eve) {
$event = new \yii2fullcalendar\models\event();
$event->id = $eve->id;
$event->title = $eve->title;
$event->start = $eve->created_date;
$tasks[] = $event;
}
return $this->render('index', ['events' => $tasks]);
}
示例10: actionSubscribe
/**
* AJAX
* Добавляет site_update
* Делает рассылку
*
* @param integer $id - идентификатор события
*
* @return string
*/
public function actionSubscribe($id)
{
$item = \app\models\Event::find($id);
if (is_null($item)) {
return self::jsonError(101, 'Не найдено событие');
}
$start = microtime(true);
Subscribe::add($item);
SiteUpdate::add($item);
$item->update(['is_added_site_update' => 1]);
\Yii::info(microtime(true) - $start, 'gs\\actionSubscribe');
return self::jsonSuccess();
}
示例11: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Event::find();
$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, 'created_date' => $this->created_date]);
$query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description]);
return $dataProvider;
}
示例12: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Event::find();
$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, 'start' => $this->start, 'finish' => $this->finish, 'is_allday' => $this->is_allday, 'created' => $this->created]);
$query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'roomid', $this->roomid])->andFilterWhere(['like', 'note', $this->note]);
return $dataProvider;
}
示例13: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Event::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'start' => $this->start, 'end' => $this->end, 'active' => $this->active]);
$query->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}
示例14: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request, $eventId)
{
$input = Input::except('token');
$roomId = Event::find($eventId)->room->id;
$tableType = $table = new Table();
$validator = $table->getValidator($input);
if ($validator->fails()) {
return $this->respondInvalidData($validator->errors());
}
$table->fill($input);
$table->room_id = $roomId;
$table->save();
return $this->respondCreateSuccess('Table: ' . $table->table_name . ' created');
}
示例15: validateTime1
public function validateTime1($attribute)
{
if (!$this->hasErrors()) {
if ($this->isNewRecord) {
$timeprov = Event::find()->where(['date_event' => $this->date_event, 'id_zal' => $this->id_zal])->all();
foreach ($timeprov as $timeprovdet) {
$t = explode(' - ', $timeprovdet->time_event);
if ($this->time_c >= $t[0] and $this->time_c <= $t[1]) {
$this->addError($attribute, 'В это время зал занят');
}
}
}
}
}