hschillig Posted January 19, 2014 Share Posted January 19, 2014 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? Quote Link to comment Share on other sites More sharing options...
Solution hschillig Posted January 19, 2014 Author Solution Share Posted January 19, 2014 Omg nevermind. So sorry for the post.. Apologies. I wasn't observing enough. I called Verify::forgotPassword instead of User::forgotPassword so it would use the User properties and not the Verify's default properties. Quote Link to comment Share on other sites More sharing options...
trq Posted January 20, 2014 Share Posted January 20, 2014 Why on earth would a User type extend a Verify type? This makes absolutely no sense in OOP. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.