ViroManchego Posted April 2, 2021 Report Posted April 2, 2021 this code on a plugin event public function preAction($event) { Loader::loadModels($this, array("Clients","Companies","ApiKeys","Users")); // $client = $this->Clients->getByUserId(2, true); $post = [ 'company_id'=>1, 'user'=>rand(), 'notes'=>'' ]; $userKey = $this->ApiKeys->add($post); if (($errors = $this->ApiKeys->errors())) { d($errors); } d( $this->ApiKeys->lastInsertId()); } on refreshing /admin/settings/system/api/ page inserts 2 users instead of one My guess is that preAction event run twice Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.