Pārlūkot izejas kodu

Adapter le système des utilisateurs du backend pour gérer le multi-boulangerie

prodstable
keun pirms 8 gadiem
vecāks
revīzija
67dddaa768
5 mainītis faili ar 84 papildinājumiem un 3 dzēšanām
  1. +1
    -0
      backend/controllers/ProduitController.php
  2. +13
    -2
      backend/controllers/UserController.php
  3. +1
    -1
      common/models/User.php
  4. +46
    -0
      common/models/UserBoulangerie.php
  5. +23
    -0
      console/migrations/m161014_084709_table_user_boulangerie.php

+ 1
- 0
backend/controllers/ProduitController.php Parādīt failu

@@ -9,6 +9,7 @@ use yii\filters\AccessControl;
use common\models\Produit;
use common\models\Production;
use common\models\User;
use common\models\UserBoulangerie;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException;

+ 13
- 2
backend/controllers/UserController.php Parādīt failu

@@ -48,7 +48,12 @@ class UserController extends Controller
public function actionIndex()
{
$dataProvider = new ActiveDataProvider([
'query' => User::find(),
'query' =>
(new \yii\db\Query())
->select('*')
->from('user, user_boulangerie')
->where('user.id = user_boulangerie.id_user')
->andWhere('user_boulangerie.id_boulangerie = '.Yii::$app->user->identity->id)
]);

return $this->render('index', [
@@ -141,7 +146,13 @@ PS : Si vous ne souhaitez plus recevoir ces emails, rendez-vous dans votre compt
}*/
$users = User::find()->all() ;
$users = (new \yii\db\Query())
->select('*')
->from('user, user_boulangerie')
->where('user.id = user_boulangerie.id_user')
->andWhere('user_boulangerie.id_boulangerie = '.Yii::$app->user->identity->id)
->all() ;
$arr_users = [] ;
foreach($users as $u)
$arr_users[] = $u->email ;

+ 1
- 1
common/models/User.php Parādīt failu

@@ -230,6 +230,6 @@ class User extends ActiveRecord implements IdentityInterface
public function isBoulanger()
{
return $this->is_boulanger ;
}
}
}

+ 46
- 0
common/models/UserBoulangerie.php Parādīt failu

@@ -0,0 +1,46 @@
<?php

namespace common\models;

use Yii;
use yii\helpers\Html ;

/**
* This is the model class for table "user_boulangerie".
*
* @property integer $id
* @property integer $id_user
* @property integer $id_boulangerie
*/
class UserBoulangerie extends \yii\db\ActiveRecord
{

/**
* @inheritdoc
*/
public static function tableName()
{
return 'user_boulangerie';
}

/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_user', 'id_boulangerie'], 'required'],
[['id_user', 'id_boulangerie'], 'integer'],
];
}

/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
];
}
}

+ 23
- 0
console/migrations/m161014_084709_table_user_boulangerie.php Parādīt failu

@@ -0,0 +1,23 @@
<?php

use yii\db\Schema;
use yii\db\Migration;

class m161014_084709_table_user_boulangerie extends Migration
{
public function up()
{
$this->createTable('user_boulangerie', [
'id' => 'pk',
'id_user' => Schema::TYPE_INTEGER . ' NOT NULL',
'id_boulangerie' => Schema::TYPE_INTEGER . ' NOT NULL',
]);

}

public function down()
{
$this->dropTable('user_boulangerie');
}
}

Notiek ielāde…
Atcelt
Saglabāt