Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sarathiscookie's avatar

Laravel cashier with stripe got some error

When I am using skipTrial(). I am getting some error given below.

$user = Auth::user(); $user->subscription('main')->skipTrial()->swap(Input::get('plan')); return redirect(url('/home'))->with('skipTrialUpdatedNotice', 'You skipped trial and plan changed. Thanks');

BadMethodCallException in Builder.php line 2258: Call to undefined method Illuminate\Database\Query\Builder::skipTrial() in Builder.php line 2258 at Builder->__call('skipTrial', array()) at Builder->skipTrial() at call_user_func_array(array(object(Builder), 'skipTrial'), array()) in Builder.php line 1340 at Builder->__call('skipTrial', array()) at Builder->skipTrial() at call_user_func_array(array(object(Builder), 'skipTrial'), array()) in Model.php line 3493 at Model->__call('skipTrial', array()) in SubscriptionController.php line 37 at Subscription->skipTrial() in SubscriptionController.php line 37 at SubscriptionController->skipTrialUpdate() at call_user_func_array(array(object(SubscriptionController), 'skipTrialUpdate'), array()) in Controller.php line 80 at Controller->callAction('skipTrialUpdate', array()) in ControllerDispatcher.php line 146 at ControllerDispatcher->call(object(SubscriptionController), object(Route), 'skipTrialUpdate') in ControllerDispatcher.php line 94 at ControllerDispatcher->Illuminate\Routing{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52 at Pipeline->Illuminate\Routing{closure}(object(Request))

0 likes
13 replies
renedekat's avatar

@sarathiscookie "Call to undefined method " I don't know what the subscription method in your $user object returns, but that object does not have a skipTrial method.

sarathiscookie's avatar

@renedekat Atpresent current user has " medium " plan and it is 10 days trial. when I echo $user I am getting

"id" => 8 "company_id" => 8 "name" => "sarath" "lastname" => "TS" "email" => "sarath@gmail.com" "password" => "$2y$10$M2JsolrAZhOSA5AYdZyT.OkSD/rNyExAHIdCBvJxSAwV3wXXYpOnS" "phone" => "9562903203" "street" => "kochi" "postal" => "682026" "city" => "Kochi" "state" => "kerala" "country" => "India" "stripe_id" => "cus_8JKkdqMaqjKIye" "card_brand" => "Visa" "card_last_four" => "4242" "trial_ends_at" => null "remember_token" => null

renedekat's avatar

@sarathiscookie That's fine, but what does the subscription method in your user model look like? You're calling this "$user->subscription('main')"

And on the result of that you call "skipTrial()" . The subscription method returns an object that does not have a skipTrial method. So, found out what subscription() returns, find that model and inspect it.

sarathiscookie's avatar

@renedekat I have checked. When I echo dd($user->subscription('main')); Iam getting "id" => 6 "user_id" => 8 "name" => "main" "stripe_id" => "sub_8JKkKj7DFCZ4f4" "stripe_plan" => "medium" "quantity" => 1 "trial_ends_at" => "2016-05-01 13:42:47" "ends_at" => null "created_at" => "2016-04-21 13:42:47" "updated_at" => "2016-04-21 13:42:47"

renedekat's avatar

@sarathiscookie I've looked at the documentation and skipTrial only seems available in version 5.2 . Which version of Laravel are you using? 5.1 by any chance?

sarathiscookie's avatar

@renedekat Sure, please check below data namespace App; use Illuminate\Foundation\Auth\User as Authenticatable; use Laravel\Cashier\Billable; class User extends Authenticatable { use Billable; public $timestamps = false; protected $fillable = [ 'name', 'lastname', 'email', 'password', 'phone', 'street', 'postal', 'city', 'state', 'country', ]; protected $hidden = [ 'password', 'remember_token', ]; public function userCompany() { return $this->belongsTo('App\Company','company_id'); } }

renedekat's avatar

@sarathiscookie Do you have this code available somewhere so I can debug it locally? Have you tried it with a bare bones Laravel installation? It's starting to annoy me now that I can't figure it out :-) Would be easier when I can debug it myself.

Please or to participate in this conversation.