@@ -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; |
@@ -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 ; |
@@ -230,6 +230,6 @@ class User extends ActiveRecord implements IdentityInterface | |||
public function isBoulanger() | |||
{ | |||
return $this->is_boulanger ; | |||
} | |||
} | |||
} |
@@ -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', | |||
]; | |||
} | |||
} |
@@ -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'); | |||
} | |||
} |