Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ipewds's avatar

Registration working but not saving in domain

In local development my registration works perfectly but when I deployed it in laravel forge with digital ocean it returns the message "Registered Successfully" but no user is being saved in the database. I just created an route to return all the User so it on a page. I'm using Eloquent Models for my database processes btw.

0 likes
6 replies
Jaytee's avatar

Make sure you've set your database credentials up properly for production

ipewds's avatar

I'm sure my credentials are set properly. Because if it isn't laravel should throw a message right? It would say a connection cannot be made.

Jaytee's avatar

Not if you had the environment variables all configured for production i don't think you would.

Have you got validation in place? There could be a column in the database that is not nullable that is not being filled and if no validation is present, it will continue.

Also check for mass assignment issues, make sure your user model allows for everything that needs mass assigning.

ipewds's avatar

well my code only goes like this really.

User Repo.

    $userId = Uuid::generate();
        $user = new User;
        $user->id = $userId ;
        $user->email = $data['email'];
        $user->password = bcrypt($data['password']);
        $user->save();
        $companyData = ['name' => $data['name'], 'userId' => $userId];
        $this->companyRepository->SaveCompany($companyData);

Company Repo

    DB::beginTransaction();
        $company = new Company;
        $company->id = Uuid::generate();
        $company->userId = $data['userId'];
        $company->name = $data['name'];
        $company->save();
            

It is just basic approach for the eloquent save.

ipewds's avatar

and the save controller

public function CreateNewCompanyAccount(Request $request) { $validator = Validator::make($request->all(), [ 'email' => 'required|email', 'name' => 'required', 'password' => 'required', ]);

    if ($validator->fails()) {
        return redirect('post/create')->withErrors($validator)->withInput();
    }

    $data = [
        'name' => $request->input('name'),
        'email' => $request->input('email'),
        'password' => $request->input('password'),
    ];

    if(count(User::where('email', '=', $request->input('email'))->get()) > 0)
    {
        return redirect('/register')->with('success', 'Work email already exists.');
    }
    $this->userRepository->SaveUser($data);

    return redirect('/register')->with('success', 'Company successfully registered.');
}
ipewds's avatar
ipewds
OP
Best Answer
Level 1

Nevermind Solved it. My env was set to debug false and that's why it ain't throwing any error. and Also I removed the DB::beginTransaction and that fixed the problem on saving the data and my vendor folder was not pushed on github that's why it threw Class not found. Thanks btw.

Please or to participate in this conversation.