@JarekTkaczyk You're right, your test clearly shows it doesn't work. You missed only one detail -- your test is not even close to the way I said it could be done (or even the way it should be done). But you knew that, didn't ya? ;)
My god man, you are twisting my words into a way which is not correct in order to show me that I'm not correct. DID I POST THAT m/d/Y WAS AN APPROVED FORMAT? No. I have NOT ONCE said that. If your test actually implemented any of the actual four methods I stated then you are guaranteed a successful result.
I'm not claiming I know better -- you came on here telling me "close, but not there yet" as if you know better. The attitude in which you say you hate I am getting from you. You really think you're being a nice guy to me? This is the second time you've stomped through a thread to go out of your way to insult me.
Let me educate you:
use Illuminate\Database\Eloquent\Model;
class Test extends Model {
protected $dates = ['dob'];
}
$test = new Test;
$test->dob = Carbon::parse('September 13, 1922');
echo $test->dob; // 1922-09-13 00:00:00
$test->dob = '1922-9-13';
echo $test->dob; // 1922-09-13 00:00:00
$test->dob = strtotime('September 13, 1922');
echo $test->dob; // 1922-09-13 00:00:00
Heh, I must be slightly better at programming than you, I was able to set the date in three different ways without firing an exception?
This is why I find you to be quite an asshole right now, definitely not a "nice guy". You chose to test the only format which I didn't state was acceptable to prove that I was wrong because you know every other option was correct. There is no other explanation for why you chose to test the only option you knew would fail. An option that I never even stated would work. You simply wanted to prove me wrong even if you were proving me wrong for something I was not wrong about. You are not being helpful to the community or the original poster at all, you are simply fishing for a way to put me down.
Don't try and patronize me now telling me that you said I was correct about returning a Carbon instance. I am also correct in the other parts of what I am saying -- if you are too novice to understand why, then so be it, but as a student you need to have a better attitude towards learning other than your current I know better and this is the way it should be done. The fact is what the original poster is trying to do can be done in numerous different ways (as I have just proven with my code snippet) without the need to add hackish mutators onto his model.
I'm through with you. I already told you in the first conversation that I would steer clear from you because I did not like your attitude. I especially do not like your attitude in this conversation. I will avoid conversation with you throughout the rest of this forum and I ask that you please do the same.