Support the ongoing development of Laravel.io →
posted 9 years ago
Database
Last updated 2 years ago.
0

Check if there's a free Laracast on this subject, I believe there is.
But basically you are getting the data from a form and inserting it into the database.
Something like:

public function postRegister(RegisterRequest $request)
       	{
		$user = new \App\User(); 
                $user->userid = $request->input('userid');
                $user->password = \Illuminate\Support\Facades\Hash::make($request->input('password'));
                $user->save();
                $this->auth->login($user);

		return redirect('where ever');
	}

Of course you may want to validate the data.
If you are new to L5, STOP / HALT, view as many free laracast as you can first, and you'll have a better understanding of things.

0
Solution

Thanks Jim for your answer. I added Stats::create([]); in my app/services/Registrar.php.

	public function create(array $data)
	{
        Stats::create([]); // Added this code

		return User::create([
			'username' => $data['username'],
			'email' => $data['email'],
			'password' => bcrypt($data['password']),
		]);
	}

This seems very ugly but I only have defaults value in this table so I thought why not

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

royal royal Joined 22 Apr 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.