'Call to a member function paymentMethods() on null
I am working on creating a subscription module in laravel and facing this issue "Call to a member function paymentMethods() on null". Here is my code can anyone suggest to me why I am facing this issue.
Call to a member function payment methods() on null
<?php
namespace App\Http\Controllers;
use App\Models\plan;
use Stripe;
use Exception;
use Illuminate\Http\Request;
use App\Models\User;
use Session;
use Illuminate\Support\Facades\Hash;
class PlanController extends Controller
{
public function index()
{
$plans = Plan::all();
return view('plans.index', compact('plans'));
}
public function show(plan $plan, Request $request)
{
$paymentMethods = $request->user()->paymentMethods();
$intent = $request->user()->createSetupIntent();
return view('plans.show', compact('plan', 'intent'));
}
}
Solution 1:[1]
Do you have $request->user() configured?
Perhaps you meant Auth::user()
Try Auth::user()->paymentMethods(); instead
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mátyás Gr?ger |
