Support the ongoing development of Laravel.io →
Authentication Security Database
Last updated 4 months ago.
0

Any reason you're not using Eloquent? Something like this would work with Eloquent:

public function getActive()
{
	// find the user, if no user found then throw an error
	$user = User::where('email', Input::get('email'))
		->where('hash', Input::get('hash'))
		->where('active', 0)
		->findOrFail();
	
	// set the active field to 1
	$user->active = 1;
	// save the user
	$user->save();
	
	// redirect user to /activated
	return Redirect::to('activated');
}

Also you could create a notActivated query scope to make the code cleaner in your controller if you wanted to.

Last updated 4 months ago.
0

I am using Eloquent, I will try that and see if it works. I thought i had to use the DB function to do any database related things?

Last updated 4 months ago.
0

Eloquent is the Laravel ORM, Eloquent provides a ton of helpful methods for interacting with databases, DB is a way to bypass Eloquent (and any other Laravel magic) to run raw SQL queries.

You can read more about Eloquent here: http://laravel.com/docs/eloquent

Last updated 4 months ago.
0

Sign in to participate in this thread!

Cloudways

Your banner here too?

Daeity daeity Joined 9 Mar 2014

Moderators

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

Your logo here?

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

© 2022 Laravel.io - All rights reserved.