use Illuminate\Support\Facades\Cache;
use Illuminate\Database\Eloquent\Model;
class Sponsor extends Model
{
//
public function getRows()
{
return Cache::remember('sponsors', now()->addHours(12), function () {
return collect($this->fetchRawSponsors())
->map(function ($sponsor) {
return [
'id' => $sponsor['sponsorEntity']['id'],
'tier_id' => $sponsor['tier']['id'],
'tier_name' => $sponsor['tier']['name'],
'tier_description' => $sponsor['tier']['descriptionHTML'],
'tier_price' => $sponsor['tier']['monthlyPriceInDollars'],
'tier_price_in_cents' => $sponsor['tier']['monthlyPriceInCents'],
'username' => $sponsor['sponsorEntity']['login'],
'name' => $sponsor['sponsorEntity']['name'],
'email' => $sponsor['sponsorEntity']['email'],
'avatar' => $sponsor['sponsorEntity']['avatarUrl'],
'location' => $sponsor['sponsorEntity']['location'],
'website' => $sponsor['sponsorEntity']['websiteUrl'],
'created_at' => $sponsor['createdAt'],
'url' => $sponsor['sponsorEntity']['url'],
];
})
->toArray();
});
}
//
}