how about
dd($user->fresh()->activities)
Summer Sale! All accounts are 50% off this week.
For one of my tests i try to update the created_at timestamp.
But this update will be completely ignored. I don't know why.
The test
public function it_fetches_a_feed_for_any_user ()
{
$user = $this->signIn();
factory(Ticket::class, 2)->create(['user_id' => $user->id]);
$user->activities->first()->update(['created_at' => Carbon::now()->subWeek()]);
$feed = Activity::feed($user);
$this->assertTrue($feed->keys()->contains(Carbon::now()->format('Y-m-d')));
$this->assertTrue($feed->keys()->contains(Carbon::now()->subWeek()->format('Y-m-d')));
}
The feed function at my Activity class
public static function feed (User $user, $number_of_activities = 25)
{
return static::where('user_id', $user->id)
->latest()
->with('subject')
->take($number_of_activities)
->get()
->groupBy(function ($activity) {
return $activity->created_at->format('Y-m-d');
});
}
This is also one of my settings in the Activity class
protected $guarded = [];
When i dump and die the activities I see the next result
dd($user->activities)
...
#original: array:6 [
"user_id" => "1"
"type" => "created_ticket"
"subject_id" => "1"
"subject_type" => "App\Ticket"
"created_at" => "2019-09-27 13:06:00"
"updated_at" => "2019-10-04 13:06:00"
]
#changes: array:1 [
"created_at" => "2019-09-27 13:06:00"
]
...
But when I dump and die the actual feed, this is completely gone.
What am I missing?
Please or to participate in this conversation.