本文整理汇总了PHP中app\models\Event::findOne方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::findOne方法的具体用法?PHP Event::findOne怎么用?PHP Event::findOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Event
的用法示例。
在下文中一共展示了Event::findOne方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findModel
protected function findModel($id)
{
if (($model = Event::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
示例2: loadModel
/**
* Загружает запись модели текущего контроллера по айдишнику
* @param $id
* @return null|static
* @throws \yii\web\HttpException
*/
public function loadModel($id)
{
$model = Event::findOne($id);
if ($model === null) {
throw new \yii\web\HttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例3: actionSend
public function actionSend()
{
// //broadcast semua
// $email = new Email();
// if ($email->load(Yii::$app->request->post()) && $email->validate()) {
// $peserta = Peserta::find()->all();
// foreach($peserta as $key){
// $temp = $key->email;
// echo $temp;
// $content_template = $email->content;
// //mengambil subjek dari email yang akan dikirimkan
// $subject_template = $email->subject;
// $subject = str_replace("{nama}", $key->nama, $subject_template);
// $content = str_replace("{nama}", $key->nama, $content_template);
// echo "</br>";
// Yii::$app->mailer
// ->compose()
// ->setFrom(Yii::$app->params['adminEmail'])
// ->setHtmlBody($content)
// ->setSubject($subject)
// ->setTo($temp)
// ->send();
// }
// }
//send per event
$email = new Email();
if ($email->load(Yii::$app->request->post()) && $email->validate()) {
//mengambil event yang dipilih
$event = Event::findOne($email->id_event);
//mengambil content dari email yang akan dikirimkan
$content_template = $email->content;
//mengambil subjek dari email yang akan dikirimkan
$subject_template = $email->subject;
foreach ($event->absensis as $absensi) {
$temp = $absensi->idPeserta->email;
echo $temp;
// echo $absensi->idPeserta->email;
echo "</br>";
$subject = str_replace("{nama}", $absensi->idPeserta->nama, $subject_template);
$subject = str_replace("{nama_seminar}", $event->nama, $subject);
$subject = str_replace("{jadwal}", $event->jadwal, $subject);
$content = str_replace("{nama}", $absensi->idPeserta->nama, $content_template);
$content = str_replace("{nama_seminar}", $event->nama, $content);
$content = str_replace("{jadwal}", $event->jadwal, $content);
Yii::$app->mailer->compose()->setFrom(Yii::$app->params['adminEmail'])->setHtmlBody($content)->setSubject($subject)->setTo($temp)->send();
}
}
}
示例4: foreach
<?php
use app\models\Event;
use app\models\Cart;
$_event = Event::findOne(2);
$carts = Cart::findAll(['status' => Cart::CART_SOLD]);
$sold_tickets = [];
foreach ($carts as $cart) {
$items = $cart->items;
foreach ($items as $i) {
if (!isset($sold_tickets[$i->ticket_id])) {
$sold_tickets[$i->ticket_id] = 0;
}
$sold_tickets[$i->ticket_id] += $i->quantity;
}
}
$sold_total = 0;
$total_tickets_sold = 0;
$this->title = Yii::t('app', 'Event Summary');
?>
<div class="foxden-default-index">
<h1><?php
echo $this->title;
?>
</h1>
<?php
foreach ($_event->ticketGroups as $group) {
if (sizeof($_event->ticketGroups) > 1) {
?>
<h2><?php
echo $group->name;
示例5: findModelBySlug
/**
* Finds the Event model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param string $slug
* @return Event the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModelBySlug($slug)
{
if (($model = Event::findOne(['slug' => $slug])) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
示例6: actionEntry
public function actionEntry()
{
$model = new AbsensiForm();
$data = Event::find()->all();
if ($model->load(Yii::$app->request->get()) && $model->validate()) {
$event = Event::findOne($model->id_event);
return $this->render('absensi-confirm', ['event' => $event]);
} else {
return $this->render('absensi', ['model' => $model, 'data' => $data]);
}
}
示例7: actionSearch
/**
* Поиск Sphinx айтемов и событий
* @return string
*/
function actionSearch()
{
if (Yii::$app->getRequest()->getQueryParam('user')) {
$user = MarkUser::findOne(Yii::$app->getRequest()->getQueryParam('user'));
if (!$user) {
return 'Доступ запрещен!';
}
if (Yii::$app->getRequest()->getQueryParam('text')) {
$items_records = [];
$events_records = [];
$query = new Query();
// $search_result = $query_search->from('siteSearch')->match($q)->all(); // поиск осуществляется по средством метода match с переданной поисковой фразой.
$query_items_ids = $query->from('items')->match(Yii::$app->getRequest()->getQueryParam('text'))->all();
foreach ($query_items_ids as $arr_item_rec) {
foreach ($arr_item_rec as $id) {
$items_records[] = Items::findOne((int) $id);
}
}
//return $this->renderPartial('searched', ['items_rows' => $items_records, 'events_rows' => 2]);
$query_events_ids = $query->from('events')->match(Yii::$app->getRequest()->getQueryParam('text'))->all();
foreach ($query_events_ids as $arr_event_rec) {
foreach ($arr_event_rec as $id) {
$events_records[] = Event::findOne((int) $id);
}
}
//var_dump($events_records); exit;
sort($events_records);
krsort($events_records);
return $this->renderPartial('searched', ['items_rows' => is_array($items_records) && !empty($items_records) && $items_records ? $items_records : 'Ничего не найдено', 'events_rows' => is_array($events_records) && !empty($events_records) && $events_records ? $events_records : 'Ничего не найдено']);
}
return $this->renderPartial('search_form');
}
}