Replace arrays with Tweet model
This commit is contained in:
parent
482df07a6d
commit
c18fcd0e2e
5 changed files with 34 additions and 15 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Model\Tweet;
|
||||
use Codebird\Codebird;
|
||||
use Tightenco\Collect\Support\Collection;
|
||||
|
||||
|
@ -56,13 +57,13 @@ class TweetFetcher
|
|||
}
|
||||
|
||||
return collect($response->get('statuses'))
|
||||
->map(function (\stdClass $tweet) {
|
||||
return [
|
||||
'id' => $tweet->id,
|
||||
'created' => strtotime($tweet->created_at),
|
||||
'text' => $tweet->text,
|
||||
'author' => $tweet->user->screen_name,
|
||||
];
|
||||
->map(function (\stdClass $status) {
|
||||
return tap(new Tweet(), function (Tweet $tweet) use ($status) {
|
||||
$tweet->setId($status->id);
|
||||
$tweet->setText($status->text);
|
||||
$tweet->setCreated(strtotime($status->created_at));
|
||||
$tweet->setAuthor($status->user->screen_name);
|
||||
});
|
||||
})->reverse();
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue