/** @test */
 public function it_stores_workgroup()
 {
     $dbUserRepository = new DbUserRepository();
     $user = factory(User::class)->create();
     $companyRepresentativeUser = $dbUserRepository->assignCompanyRepresentativeRole($user);
     $dbWorkgroupRepository = new DbWorkgroupRepository();
     $workgroupModel = new Workgroup();
     $workgroupFillableKeys = $workgroupModel->getFillable();
     $expectedWorkgroupData = array_only(factory(Workgroup::class, 'relationless')->make()->toArray(), $workgroupFillableKeys);
     $this->dontSeeInDatabase('workgroups', $expectedWorkgroupData);
     $workgroup = $dbWorkgroupRepository->storeAndAssignCreatorByUser($expectedWorkgroupData, $companyRepresentativeUser);
     $this->assertNotFalse($workgroup);
     $this->seeInDatabase('workgroups', $expectedWorkgroupData);
 }
 /**
  * Store a workgroup.
  *
  * @param $data
  * @param User $user
  * @return Workgroup|false
  */
 public function storeAndAssignCreatorByUser($data, User $user)
 {
     $workgroup = new Workgroup(array_only($data, $this->getModel()->getFillable()));
     $workgroup->creator()->associate($user);
     return $workgroup->save() ? $workgroup : false;
 }