Jump to content

Extended class property won't override?


hschillig
Go to solution Solved by hschillig,

Recommended Posts

Ok so I have a Verify object.

class Verify extends Ardent {

	protected $table;

	public $autoPurgeRedundantAttributes = true;
	public static $passwordAttributes  = array('password');
	public $autoHashPasswordAttributes = true;

	public static $rules = array(
	    'email'                 => 'required|unique:users,email|email',
	    'password'              => 'required|confirmed',
	    'password_confirmation' => 'required',
	    'fname'                 => 'required|max:30',
	    'lname'                 => 'required|max:40',
	    'address'               => 'required|max:50',
	    'city'                  => 'required|max:50',
	    'state'                 => 'required|max:2',
	    'zip'                   => 'required|max:6',
	    'phone'                 => 'required|max:15'
	);

	protected $fillable = array('email', 'password', 'fname', 'lname', 'address', 'city', 'state', 'zip', 'phone');

	protected $status = array(
		0 => 'inactive',
		1 => 'confirmed'
	);

	protected $identify = 'email'; // identify column in the db

}

But when I extend it and try to overwrite the $identify property, it still uses the 'email' value instead:

<?php namespace Intellect\Alkharia\Models\User;

use Intellectproductions\Verify\Verify;
use Zizaco\Entrust\HasRole;

class User extends Verify {

	public static $rules = array(
		'username'              => 'required|alpha_dash|unique:users,username|max:30',
	    'email'                 => 'required|unique:users,email|email|max:50',
	    'password'              => 'required|confirmed',
	    'password_confirmation' => 'required',
	    'name'                  => 'required|max:35',
	    'birthday'              => 'required|date_format:Y-m-d',
	    'verification'          => 'required|equals:4'
	);

	protected $fillable = array('username', 'email', 'password', 'name', 'birthday');

	protected $identify = 'username'; // identify column in the db
}

But all the other properties successfully overrode.

 

Here is the method in the Verify object:

         /**
	 * Forgot password
	 *
	 */
	public function forgotPassword($username) {
		dd($this->identify);

		$user = Verify::where($this->identify, $username)->first(array('id', 'email', 'username'));
		dd($user);

		if($user) {

			// user was found so generate token and send email
			$token = md5( uniqid(mt_rand(), true) );

	        $values = array(
	            'email'=> $user->email,
	            'token'=> $token,
	            'created_at'=> new \DateTime
	        );

	        \DB::connection()->table('password_reminders')
	            ->insert( $values );

	        $this->sendResetEmail(array('user' => $user, 'token' => $token));

	        \Session::flash('message', 'Your instructions on how to reset your password has been sent to your email.');
	        return true;

		} else {

			\Session::flash('error', 'That email does not exist!');
			return false;

		}

	}

dd($this->identify) will spit on the value of it. And it says 'email' still, not 'username'.. Any ideas on why?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.