<commit_before><?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use yii\widgets\ListView;
use yii\data\ArrayDataProvider;

/* @var $this yii\web\View */
/* @var $model app\models\Organizer */

$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Organizers', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="organizer-view">

    <h1><?= Html::encode($this->title) ?></h1>

    <p>
        <?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
        <?= Html::a('Delete', ['delete', 'id' => $model->id], [
            'class' => 'btn btn-danger',
            'data' => [
                'confirm' => 'Are you sure you want to delete this item?',
                'method' => 'post',
            ],
        ]) ?>
    </p>


    <h2>Information</h2>
    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            //'id',
            'name',
            'created_at',
            'updated_at',
        ],
    ]) ?>

    <?php 
        $polls = $model->getPolls()->all();
        $allModels = [];
        foreach ($polls as $poll) {
            //$attributes[] = ['label' => $poll->created_at, 'value' => $poll->question];
            $allModels[] = ['key' => "$poll->question"];
        }

        $dataProvider = new ArrayDataProvider([
            'allModels' => $polls,//$allModels,
        ]);
    ?>

    <?php if (count($polls) > 0) { echo "<h2>Polls</h2>"; } ?>

    <?= ListView::widget([
        'dataProvider' => $dataProvider,
        'itemView' => function($model, $key, $index, $widget) {
            return Html::a(Html::encode($model->question), ['poll/view', 'id' => $model->id], []);
        }
    ]) ?>

</div><commit_msg>Show no polls section when an organizer has no polls<commit_after><?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use yii\widgets\ListView;
use yii\data\ArrayDataProvider;

/* @var $this yii\web\View */
/* @var $model app\models\Organizer */

$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Organizers', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="organizer-view">

    <h1><?= Html::encode($this->title) ?></h1>

    <p>
        <?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
        <?= Html::a('Delete', ['delete', 'id' => $model->id], [
            'class' => 'btn btn-danger',
            'data' => [
                'confirm' => 'Are you sure you want to delete this item?',
                'method' => 'post',
            ],
        ]) ?>
    </p>


    <h2>Information</h2>
    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            //'id',
            'name',
            'created_at',
            'updated_at',
        ],
    ]) ?>

    <?php 
        $polls = $model->getPolls()->all();
        $allModels = [];
        foreach ($polls as $poll) {
            //$attributes[] = ['label' => $poll->created_at, 'value' => $poll->question];
            $allModels[] = ['key' => "$poll->question"];
        }

        $dataProvider = new ArrayDataProvider([
            'allModels' => $polls,//$allModels,
        ]);
    ?>

    <?php
        if (count($polls) > 0) {
            echo Html::tag('h2', 'Polls');
            echo ListView::widget([
                'dataProvider' => $dataProvider,
                'itemView' => function($model, $key, $index, $widget) {
                    return Html::a(Html::encode($model->question), ['poll/view', 'id' => $model->id], []);
                }
            ]);
        }
    ?>

</div>
{'fraction_non_alphanumeric': 0.22616771373941547, 'fraction_numerical': 0.0035509423654739142, 'mean_word_length': 2.067001675041876, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 104, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6167770', 'n_tokens_mistral': 1227, 'n_tokens_neox': 1200, 'n_words': 226}