Laravel Cashier (Billing)
Hello everybody
I have a problem with Laravel Cashier. Here's what I've done
- I Installed laravel/cashier with composer require (controll in composer.json file its installed)
- I updated my composer file
- I registred Laravel\Cashier\CashierServiceProvider in my config file.
- I Copyied all of migration in my users_table an migrate that
- I setup my Model with "use Laravel\Cashier\Billable;" and with "use Billable;" in my User Class
- I copy the empedet Form from Stripe and paste that in my test page
My Problem:
When i write the Code like this in the documentation
$user = Auth::id();
$user->newSubscription('main', 'monthly')->create($creditCardToken);
But with this code became a failre
Call to a member function newSubscription() on integer
I can change the variable creditCardToken with the _token, but its not work. What i make false?
I hope you can Help my
Best regards
Christoph
@cschoeni It’s because you’re fetching the user’s ID, and not the User model instance.
It should be:
$user = Auth::user();
Not:
$user = Auth::id();
Also be sure to check you actually have an authenticated user first, using the auth middleware on your route.
Please or to participate in this conversation.