Open cloudswitch opened 9 years ago
If I do so in base/model: use dektrium\user\models\User as User; and public function getUser() { return $this->hasOne(User::className(), ['id' => 'UserId']); } it works.
You could use the skipRelations
option as a workaround
Like in the other issue, it's a bit tricky to link a model which is not in the generated CRUDs.
I have no clue where or how could I use this skipRelations thing, because I'm lame, but:
You said giiant is built in relation with yii2-user, and what I don't really understand is, how? Because I have to manually change for example this:
public function getUser() {
return $this->hasOne(\app\models\User::className(), ['id' => 'UserId']);
}
to
public function getUserId() {
return $this->hasOne(\dektrium\user\models\User::className(), ['id' => 'UserId']);
}
because you create the relation in views with getUserId(), and if I don't change to \dektrium\user\models\
I get error when generating CRUD. If I change, it works. But the problem is, I'm absolutely beginner and I'm just experimenting, because I have no idea why is it not working. :) I guess there is only a small bug in the code what could be easily changed to make is work properly, right? I hope so! Thanks in advance!
Fill the array of names of models that do not need to generate relations.
https://github.com/schmunk42/yii2-giiant/blob/master/src/generators/crud/Generator.php#L42 public $skipRelations = []; or https://github.com/schmunk42/yii2-giiant/blob/master/src/commands/BatchController.php#L130 public $crudSkipRelations = [];
Or are the names of relations and namespace in order.
Hi,
I have made a completely new install off yii2, than yii2-user (here I'm not sure if I must migrate or not, and if I have to do this or not: "Make sure that you don't have user component configuration in your config files" - the doc is not 100% clear), than yii2-giiant. When I generate the first model, with relation to user table, it creates the following relation: public function getUser() { return $this->hasOne(\app\models\User::className(), ['id' => 'UserId']); }
next, I want to generate Giiant-CRUD, and get the following error: PHP Fatal Error – yii\base\ErrorException Class 'app\models\User' not found
I think relation should point to some other model (model of yii2-user in vendor\dektrium\yii2-user\models\User.php), or not? Or is there something wrong with yii2-user extension, and that's why it doesn't work? I have no clue. Thanks!