passwordReminder = $passwordReminder; } /** * Set the userId and create a random token */ public function store() { $rules = [ 'user_id' => ['required'] ]; $payload = Input::only('user_id'); $validator = Validator::make($payload, $rules); if ($validator->fails()) { throw new ValidationException('Could not find user.', $validator->errors()); } $this->passwordReminder->userId = Input::get('user_id'); $this->passwordReminder->token = base64_encode(openssl_random_pseudo_bytes(64)); if ($this->passwordReminder->save()) { return $this->passwordReminder; } else { throw new \Dingo\Api\Exception\StoreResourceFailedException; } } }