Merge pull request #37 from apuc/sum_and_calendar
accesses user-card innerJoin
This commit is contained in:
commit
93be7e8d1e
@ -5,6 +5,7 @@ namespace app\modules\accesses\controllers;
|
|||||||
use backend\modules\card\models\UserCardSearch;
|
use backend\modules\card\models\UserCardSearch;
|
||||||
use common\classes\Debug;
|
use common\classes\Debug;
|
||||||
use common\models\ProjectAccesses;
|
use common\models\ProjectAccesses;
|
||||||
|
use common\models\UserCard;
|
||||||
use common\models\UserCardAccesses;
|
use common\models\UserCardAccesses;
|
||||||
use Yii;
|
use Yii;
|
||||||
use common\models\Accesses;
|
use common\models\Accesses;
|
||||||
@ -52,17 +53,11 @@ class AccessesController extends Controller
|
|||||||
{
|
{
|
||||||
$searchModel = new UserCardSearch();
|
$searchModel = new UserCardSearch();
|
||||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||||
|
$dataProvider->query->innerJoin('user_card_accesses', 'user_card.id = user_card_accesses.user_card_id');
|
||||||
// $query = \common\models\UserCard::find()->select(['id_user', 'fio', 'email']);
|
|
||||||
//
|
|
||||||
// $provider = new ActiveDataProvider([
|
|
||||||
// 'query' => $query,
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
return $this->render('index', [
|
return $this->render('index', [
|
||||||
'searchModel' => $searchModel,
|
'searchModel' => $searchModel,
|
||||||
'dataProvider' => $dataProvider,
|
'dataProvider' => $dataProvider,
|
||||||
//'provider' => $provider
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,11 +46,9 @@ class UserCardSearch extends UserCard
|
|||||||
public function search($params)
|
public function search($params)
|
||||||
{
|
{
|
||||||
$query = UserCard::find();
|
$query = UserCard::find();
|
||||||
// add conditions that should always apply here
|
$query->where(['id'])->distinct()
|
||||||
$query->where(['id'])->distinct();
|
->leftJoin('card_skill', 'card_skill.card_id=user_card.id')
|
||||||
//try join 3 tables
|
->leftJoin('skill', 'skill.id=card_skill.skill_id');
|
||||||
$query->leftJoin('card_skill', 'card_skill.card_id=user_card.id');
|
|
||||||
$query->leftJoin('skill', 'skill.id=card_skill.skill_id');
|
|
||||||
|
|
||||||
$dataProvider = new ActiveDataProvider([
|
$dataProvider = new ActiveDataProvider([
|
||||||
'query' => $query,
|
'query' => $query,
|
||||||
|
Loading…
Reference in New Issue
Block a user