Reputation: 109
I am making a RESTFUL API call through controller
. The API response returns a token
which is used for every subsequent API call. I wish to keep that data in the controller
and it can be used for different function
in the controller
. But it seems like in the route
function, the new controller
instance will always be instantiated, is it possible to using the exact same controller
across these route
?
For example, I have 3 funcitons
in the tenable controller
, I wish these 3 functions access to the same instance of controller
Route::get('/example','Tenable@sendReport');
Route::get('/posts/addscan','Tenable@addScan');
Route::get('/posts/scanreport','Tenable@addScan');
Upvotes: 0
Views: 227
Reputation: 1027
You can pass the data along with url or store it as a session variable or create a new migration for a table and store it there
Upvotes: 0
Reputation: 622
This happens because a PHP Web Application "lives" for one request, which means after the request is processed, all data will be deleted - you can't save Data between 2 requests in PHP Itself, thats why you have to use SQL / Sessions / Cookies / Caching / Files.
Upvotes: 1