Anyone know how to do this with my code please?
Dec 9, 2014
9
Level 51
Cache results with Stripe/Cashier
Hi All,
I have a repository that has a method in it like so:
public function allInvoices()
{
$user = Auth::user();
$invoices = $user->invoices();
return $invoices;
}
Which is injected into my controller, then I have a method in the controller like:
public function getInvoices()
{
$invoices = $this->provider->allInvoices();
return View::make('provider.invoices', compact('invoices'));
}
How can I use Cache remember function to cache this for a few days before making another API request to Stripe? Obviously based on my code, and I still need to pass through to the view, if any can help me with this and use my code to make the Cache work.
I am using Cashier for this and not standalone Stripe.
Thanks in advance.
Level 65
Yeah so why not just
$invoices = Cache::remember('invoices', '259200', function()
{
return $this->provider->allInvoices();
});
return View::make('provider.invoices', compact('invoices'));
$invoices will always be the same
Please or to participate in this conversation.