PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, January 30, 2022

[FIXED] How to solve error "Invalid view" in registration function?

 January 30, 2022     eloquent, laravel, laravel-5, reactjs     No comments   

Issue

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());
    }

Solution

I resolve my issue by changing the is_active parameters to 1



Answered By - Simon
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing