Здравствуйте, не могу понять почему вылетает данная ошибка:
Invalid Configuration – yii\base\InvalidConfigException
The "dataProvider" property must be set.
1. in /var/www/u0598324/public_html/webstels.com/vendor/yiisoft/yii2/widgets/BaseListView.php
Вот контроллер SupportController.php:
<?php
namespace app\controllers\user;
use app\components\Controller;
use app\helpers\UserSettingHelper;
use app\models\User;
use app\models\UserFriend;
use yii\data\Pagination;
use yii\helpers\ArrayHelper;
use yii\web\NotFoundHttpException;
use app\models\TicketBody;
use app\models\TicketFile;
use app\models\TicketHead;
use app\models\UploadForm;
use yii\filters\AccessControl;
use yii\filters\AccessRule;
use yii\helpers\Url;
use yii\web\UploadedFile;
class SupportController extends Controller
{
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'ruleConfig' => [
'class' => AccessRule::className(),
],
'rules' => [
[
'actions' => ['index', 'view', 'open'],
'allow' => true,
'roles' => ['@'],
],
],
],
];
}
/**
* Renders the index view for the module
*
* @return string
*/
public function actionIndex()
{
$this->layout = 'page';
$vars = [];
$user = User::find()->where(['username' => $_GET['username']])->one();
if ($user === null)
throw new NotFoundHttpException();
$setting = UserSettingHelper::get($user);
$vars = ArrayHelper::merge($vars, [
'user' => $user,
'setting' => $setting,
]);
$dataProvider = (new TicketHead())->dataProviderUser();
Url::remember();
return $this->render('index', $vars, ['dataProvider' => $dataProvider]);
}
}
Вот вьюха:
<div>
<?= \yii\grid\GridView::widget([
'dataProvider' => $dataProvider,
'rowOptions' => function ($model) {
return ['data-id' => $model->id, 'class' => 'ticket'];
},
'columns' => [
'department',
'topic',
[
'contentOptions' => [
'style' => 'text-align:center;',
],
'value' => function ($model) {
switch ($model['status']) {
case TicketHead::OPEN :
return '<div class="label label-default">Открыт</div>';
case TicketHead::WAIT :
return '<div class="label label -warning">Ожидание</div>';
case TicketHead::ANSWER :
return '<div class="label label -success">Отвечен</div>';
case TicketHead::CLOSED :
return '<div class="label label -info">Закрыт</div>';
}
},
'format' => 'html',
],
[
'contentOptions' => [
'style' => 'text-align:right; font-size:13px',
],
'attribute' => 'date_update',
'value' => "date_update",
],
],
]) ?>
</div>
Модель TicketHead.php:
<?php
namespace app\models;
use \app\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\data\ActiveDataProvider;
use yii\db\Expression;
use app\models\Module;
/**
* This is the model class for table "ticket_head".
*
* @property integer $id
* @property integer $user_id
* @property string $department
* @property string $topic
* @property integer $status
* @property string $date_update
*/
class TicketHead extends \yii\db\ActiveRecord
{
/**
* dataProvider для пользователей
*
* @return ActiveDataProvider
*/
public function dataProviderUser()
{
$query = TicketHead::find()->where("user_id = " . Yii::$app->user->id);
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort' => [
'defaultOrder' => [
'date_update' => SORT_DESC
]
],
'pagination' => [
'pageSize' => $this->module->pageSize
]
]);
return $dataProvider;
}
}