Answer the question
In order to leave comments, you need to log in
Yii2 how to extract nested links and get their count?
I do statistics for the user.
Days, weeks, months. year. all times and date ranges.
There are three entities on which all this is tied, they are all glued one to many
Partner-> Coupon-> Order
There is a partner_id in the coupon
table There is a partner_id, coupon_id in the order table
Everywhere there are creation dates in UNIX from the TimeStampBehavior behavior
on the controller for each period an action is created . On the front, it's just buttons.
For the whole period I did as follows. received the id of the current partner and pulled out all the coupons belonging to him. shoved it into the data provider, but on the frontend. made an additional request for counts.
provider
<table class="table table-hover">
<tr>
<td><strong>Название купона</strong></td>
<td><strong>Покупок</strong></td>
</tr>
<?= \yii\widgets\ListView::widget([
'dataProvider' => $couponsProvider,
'itemView' => '_coupons',
]) ?>
</table>
<?php
use yii\helpers\Html;
use yii\helpers\Markdown;
//получаем кол-во
$orders = \common\models\Order::find()->where(['coupon_id' => $model->id])->count(); ?>
<tr>
<td><?= Html::encode($model->title) ?></td>
<td><?= Html::encode($orders) ?></td>
</tr>
$timestamp = time();
$dates = Yii::app()->dateFormatter->format('dd-MM-yyyy', $timestamp);
$date = new DateTime($dates);
$date->modify('-1 day');
$date_elements = explode("-",$date->format('d-m-Y'));
$beforeTime = mktime(0,0,0,$date_elements[1],$date_elements[0],$date_elements[2]);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question