Hi Guys, so im very new to laravel (approx 2wks) and in all fairness i havent been programming for years, but after discovering laravel i have taken it up again, and started working on a new backend system for my company..
But i have run in to a challenge.. Simply put i have a resource-controller with a store function where i want to store a customer to our database, but at the same time push the customerdata into our accountingsystem (e-conomic).
I have tried combining putting my api-function inside my store-function but so far without any luck at all. Can someone help me in the right direction? :)
The resource-controller - store function (which works in storing it to our mysql db): https://gist.github.com/olebulow/384c99458d397dec81ba
The api-function which i want to run after storing it to our mysql db: https://gist.github.com/olebulow/bda8b648b4ed98569fec
Any help is appreciated :)
Sounds like you need another class to wrap that API call in.
Create a new class and make sure it's going to be autoloaded. You might need to create a classes directory and then in your global start file add the directory to the class loader.
Economic.php
<?php
class Economic {
public function pushCustomerData()
{
// Place your API call in here
}
}
Then from within your store
method you can get an instance of the Economic class and call the pushCustomerData
method.
$economic = new Economic;
$economic->pushCustomerData();
This is just the basic idea. You might like to create a constructor on that class to simplify a few things, especially if you have a number of API calls that you make that re-use the same connection details.
Thanks mate, got the idea.. Great input ;)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community