'user1', 'password' => '', 'email' => 'user1@example.com', 'api_key' => '', ]); $user2 = User::create([ 'name' => 'user2', 'password' => '', 'email' => 'user2@example.com', 'api_key' => '', ]); $worklog = new Worklog(); $worklog->user()->associate($user1); $worklog->creator()->associate($user2); $worklog->hours = 4.2; $worklog->comment = 'Lorem ipsum'; $worklog->worked_at = new Carbon(); $worklog->save(); $savedWorklog = Worklog::first(); $this->assertEquals($user2->name, $savedWorklog->creator->name); } }