vendredi 18 octobre 2019

How to solve error "Invalid view" in registration function?

I am having an error during the registration of a recruiter for the application I am working for

here is the error I am having in the network while sending the form information :

code:500 error: "Invalid view." message: "Erreur lors de la création du compte"

here is the code

  public function personnal(AccountCreateRequest $request)
{
    try {
        $http = new \GuzzleHttp\Client;
        $exists = false;
        $userData = $request->input('user');
        $userData['password'] = bcrypt($userData['password']);
        $userData['gender'] = ($userData['title'] === 'M.') ? 'm' : 'f';
        if (array_get($userData, 'ref')) {
            $user = User::where('ref', $userData['ref'])->firstOrFail();
            $user->fill($userData);
            $exists = true;
        } else {
            $userData['ref'] = User::generateId();
            $user = new User($userData);
        }
        $user->source = 'website';
        $user->optin_platform = 1;

        if ($user->role === 'seeker') {
            $user->is_active = 1;
            $user->save();
            $seeker = new UserSeeker([
                'registration_date' => Carbon::now(),
                'available_in'      => 1,
                'token'             => bin2hex(uniqid(rand())),
                'resume_path'       => $request->input('seeker.resume_path'),
                'resume_date'       => Carbon::now(),
            ]);
            $seeker = $user->seeker()->save($seeker);
            $seeker->location()->associate(Address::create($request->input('location')))->save();
        } else {
            $user->is_active = 0;
            $user->save();
            // $size = $request->input('company.size', $request->session()->get('info'));
            $companyData = $request->input('company');
            $company = Company::create($companyData);
            $recruiter = $user->recruiter()->save(new UserRecruiter([
                'company_id' => $company->id,
            ]));
        }
        DB::commit();
        $this->json['response'] = ['ref' => $user->ref];
        $this->json['code'] = $this->code['created'];
        dd($this->json);
    } catch (MissingParamsException $e) {
        DB::rollback();
        $this->setError($e, $e->getMessage(), 'missing');
    } catch (\Exception $e) {
        DB::rollback();
        $this->setError($e, 'Erreur lors de la création du compte');
    } finally {
        return ($this->response());
    }


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Muqqto
via IFTTT

Aucun commentaire:

Enregistrer un commentaire