Support the ongoing development of Laravel.io →
Database Eloquent Laravel.io
Last updated 1 year ago.
0

Could you provide some code? It will be easier to help ;)

0

Thanks for trying to help . Below is the code ... I have hard coded the validation of the user to dummyuser .but i would like to validate it using the database. The problem is how to fetch the data in the provider . The Eloquent ORM does not seem to work it Throws an error saying Trying to get property of non-object.

namespace App\Auth;

use App\UserPoa; use Illuminate\Auth\GenericUser; use Illuminate\Contracts\Auth\Authenticatable as UserContract; use Illuminate\Contracts\Auth\UserProvider as UserProvider;

class CustomUserProvider implements UserProvider { /** * Retrieve a user by their unique identifier. * * @param mixed $identifier * @return \Illuminate\Contracts\Auth\Authenticatable|null */ public function retrieveById($identifier) { // TODO: Implement retrieveById() method. return $this->dummyUser(); }

/**
 * Retrieve a user by by their unique identifier and "remember me" token.
 *
 * @param  mixed $identifier
 * @param  string $token
 * @return \Illuminate\Contracts\Auth\Authenticatable|null
 */
public function retrieveByToken($identifier, $token)
{
	// TODO: Implement retrieveByToken() method.
	dd(dd3);
}

/**
 * Update the "remember me" token for the given user in storage.
 *
 * @param  \Illuminate\Contracts\Auth\Authenticatable $user
 * @param  string $token
 * @return void
 */
public function updateRememberToken(UserContract $user, $token)
{
	// TODO: Implement updateRememberToken() method.
	dd(dd2);
}

/**
 * Retrieve a user by the given credentials.
 *
 * @param  array $credentials
 * @return \Illuminate\Contracts\Auth\Authenticatable|null
 */
public function retrieveByCredentials(array $credentials)
{
	// TODO: Implement retrieveByCredentials() method.


	return $this->dummyUser();

}

/**
 * Validate a user against the given credentials.
 *
 * @param  \Illuminate\Contracts\Auth\Authenticatable $user
 * @param  array $credentials
 * @return bool
 */
public function validateCredentials(UserContract $user, array $credentials)
{
	// TODO: Implement validateCredentials() method.
	// we'll assume if a user was retrieved, it's good
	return true;
}



/**
 * Return a generic fake user
 */
protected function dummyUser()
{
	$attributes = array(
		'id' =>123,
		'username' => 'chuckles',
		'password' => \Hash::make('SuperSecret'),
		'name' => 'Dummy User',
	);


	return new GenericUser($attributes);
}

}

0

Sign in to participate in this thread!

Eventy

Your banner here too?

clevegomes clevegomes Joined 26 Jul 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.

© 2024 Laravel.io - All rights reserved.