Jump to content

use Carbon\CarbonPeriod


pRieStaKos

Recommended Posts

Hello, 

I'm creating a module cronjon and I want to create a CarbonPeriod, but when I'm using `Carbon\CarbonPeriod` it returns the following error, every time I run the cronjob.

Trait 'Carbon\Traits\IntervalRounding' not found

I downloaded CarbonPeriod.php from Carbon GitHub and uploaded to `vendor/nesbot/carbon/src/Carbon/ `

I tried

use Carbon\Carbon; 
use Carbon\CarbonPeriod;

and

use WHMCS\Carbon\Carbon; 
use WHMCS\Carbon\CarbonPeriod;

without any luck.

Any suggestions ? 

I want to check if a create period `CarbonPeriod::create($service->regdate, '1 month', $service->nextduedate);` contains `Carbon::now()`

Thank you in advance.

Link to comment
Share on other sites

You mentioned you downloaded CarbonPeriod.php but the trait it complains about isn't in that file but rather it is in Carbon/Traits/IntervalRounding.php  .  And that file appears to be missing from the WHMCS copy of Carbon.   So download that one as well as any others that it may require.   Replacing the WHMCS copy with the github version might be better. 

Link to comment
Share on other sites

11 hours ago, steven99 said:

You mentioned you downloaded CarbonPeriod.php but the trait it complains about isn't in that file but rather it is in Carbon/Traits/IntervalRounding.php  .  And that file appears to be missing from the WHMCS copy of Carbon.   So download that one as well as any others that it may require.   Replacing the WHMCS copy with the github version might be better. 

Kudos @steven99. I was looking for a light version on resolving that, but uploading the latest zip from GitHub and using the following, worked !!

use WHMCS\Carbon;
use Carbon\CarbonPeriod;

Thank you.

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated