0

I have my installation of laravel 4 under HHVM, and i set up as a accessory on my eloquent an converter date from SQL date to human.

doing something like that:

public function getDateSpanAttribute($value)
{
      return $value = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s',$this->created_at)->diffForHumans();
}

This method work well under php5, no error just work. On HHVM this accessory throw me an exception saying,

{"error":{"type":"InvalidArgumentException","message":"Unknown setter '_date_time'","file":"/var/www/mynextmatch/vendor/nesbot/carbon/src/Carbon/Carbon.php","line":542}}

I saw the source of Carbon on that row and it is the magic method __get() to give this problem but i cannot figure out why it happening.

I will appreciate same help. Thanks

2 Answers 2

0

Not sure about the error on HHVM but one thing is for sure that an accessor method doesn't contain any argument, it should be (Manual):

public function getDateSpanAttribute()
{
      return \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $this->created_at)->diffForHumans();
}

You just need to return the property not setting anything, if you want to set anything then it would be a setter/mutator method which acepts a value as argument.

Sign up to request clarification or add additional context in comments.

5 Comments

True, but it doesn't matter in fact.
Confused! Won't it matter if he doesn't provide the parameter while the method accepts one ? Method will complain about it, right ? But it doesn't matter if he provide it and doesn't use it in his code, like he is doing it now @deczo.
yes true, it doesn't matter with the problem but thank you, you are right! :)
You are welcome and please post the solution as an answer when you get it fixed, I'll delete my answer @Fabrizio.
Hopefully I'll do, I'm still having this issue :/
0

I am having the same issue but think mine is tied to creating a session creation after logging in ( InvalidArgumentException Unknown setter '_date_time'). Mine is installed on HHVM 3.1 running on Ubuntu 14.04. I have the same set up using Ubuntu 12.04 and am not having this issue.

10. InvalidArgumentException
…/­vendor/­nesbot/­carbon/­src/­Carbon/­Carbon.php542
9. Carbon\Carbon __set
<#unknown>0
8. DateTime __sleep
<#unknown>0
7. serialize
…/­vendor/­laravel/­framework/­src/­Illuminate/­Session/­Store.php222
6. Illuminate\Session\Store save
…/­vendor/­laravel/­framework/­src/­Illuminate/­Session/­Middleware.php126 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.