After updating to version 7.1.1 (Updating laravel / cashier (v7.1.0 => v7.1.1): Checking out 5e2fa78a5b) the following error occurred: Call to a member function isFuture () on string.
In
/vendor/laravel/cashier/src/Billable.php
/ **
聽聽聽聽聽 * Determine if the Stripe model is a "generic" trial at the model level.
聽聽聽聽聽 *
聽聽聽聽聽 * @return bool
聽聽聽聽聽 * /
聽聽聽聽 public function onGenericTrial ()
聽聽聽聽 {
聽聽聽聽聽聽聽聽 return $ this-> trial_ends_at && $ this-> trial_ends_at-> isFuture ();
聽聽聽聽 }
This is a bug?
I am using exactly as shown in the laravel manual:
if ($user->onGenericTrial()) { // User is within their "generic" trial period... }
it was 100% and after this update the error occurred, I had to go back to the previous version. Did no one pass this or can tell me what to do?
@adrianoGaspar Adiraino Did you manage to solve this? We have got the same problem after composer update. would appreciate it if you could share your thoughts?
no, I went back to the previous version ("laravel/cashier": "7.1.0") and am waiting for some response, I posted this problem minutes after the update but so far nothing.
@adrianoGaspar Thanks for getting back to me. It's interesting as it actually works on my colleague's laptop but not mine. He is using Cashier 7.1 though.
@adrianoGaspar Hi Adriano, my talented colleague just sorted out the issue. In short, in the latest version you will need to be sure to add a date mutator for trial_ends_at to your model definition..
Like this:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = [
'created_at',
'updated_at',
'deleted_at'
];
}
After that it should all work.
As always the details. Thank you for sharing. Works perfectly now.
Most helpful comment
@adrianoGaspar Hi Adriano, my talented colleague just sorted out the issue. In short, in the latest version you will need to be sure to add a date mutator for trial_ends_at to your model definition..
Like this:
After that it should all work.