Cashier-stripe: Call to a member function isFuture () on string

Created on 6 Jun 2018  路  5Comments  路  Source: laravel/cashier-stripe

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?

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:

<?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.

All 5 comments

@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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tania-pets picture tania-pets  路  3Comments

andyrobertscarpediem picture andyrobertscarpediem  路  4Comments

VirtualDesignFactory picture VirtualDesignFactory  路  4Comments

4UForever picture 4UForever  路  3Comments

borutjures picture borutjures  路  3Comments