'Laravel IOC Binding Question - getting 500 error
I keep gettings a 500 errors, appdebug = true, but it doesn't show me exactly what the problem is. It logs all other 500 just fine.
I can make the 500 errors go away if i add the below to AppServiceProvider, AND remove PaymentInterface on __construct(PaymentInterface $service) - from MakeACardPayment.
I have to say this doesn't make any sense. The DI with 0 configuration should be taking care of this right? Suggestions on what to try here please.
// $this->app->bind(MakeACardPayment::class, function($app){
// return new MakeACardPayment();
// });
//AppServiceProvider
App::bind(PaymentInterface::class,StripePaymentService::class);
//Controller for post
class PaymentController extends Controller
{
public function store(Request $request, MakeACardPayment $cardAction)
{
dd($cardAction->execute([
'card_number'=> $request['card_number']
,'month_exp'=> $request['month_exp']
,'year_exp'=> $request['year_exp']
,'security_code'=> $request['security_code']
]));
}
}
//uses the interface binding
class MakeACardPayment
{
protected $service;
public function __construct(PaymentInterface $service){
$this->service = $service;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|