private function getNonPlannerInAGroup()
 {
     $group = \plunner\Group::has('employees', '>=', '2')->has('meetings', '>=', '1')->whereHas('employees', function ($query) {
         $query->whereNotIn('id', \plunner\Planner::all()->pluck('id'));
         //TODO do in a better way less expensive
     })->firstOrFail();
     $employee = $group->employees()->whereNotIn('id', \plunner\Planner::all()->pluck('id'))->firstOrFail();
     return [$group, $employee];
 }
 public function testIndexCurrent()
 {
     //one meeting planed new, one meeting planed old, one to be planed
     $planner = factory(\plunner\Employee::class)->make();
     $this->company->employees()->save($planner);
     $group = factory(\plunner\Group::class)->make(['planner_id' => $planner->id]);
     $this->company->groups()->save($group);
     $planner = \plunner\Planner::findOrFail($planner->id);
     //this to cast to planner type
     $group->meetings()->save(factory(\plunner\Meeting::class)->make());
     //to be planed
     $new = factory(\plunner\Meeting::class)->make(['start_time' => (new \DateTime())->add(new \DateInterval('PT100S'))]);
     $group->meetings()->save($new);
     // new planed
     $old = factory(\plunner\Meeting::class)->make(['start_time' => (new \DateTime())->sub(new \DateInterval('PT100S'))]);
     $group->meetings()->save($old);
     // old planed
     //other planner meeting planned to test or condition
     $groupOther = \plunner\Group::where('planner_id', '<>', $planner->id)->firstOrFail();
     $other = factory(\plunner\Meeting::class)->make(['start_time' => (new \DateTime())->add(new \DateInterval('PT100S'))]);
     $groupOther->meetings()->save($other);
     $response = $this->actingAs($planner)->json('GET', '/employees/planners/groups/?current=1');
     $response->assertResponseOk();
     $planner = $planner->fresh();
     $response->seeJsonEquals($planner->GroupsManaged()->with(['meetings' => function ($query) {
         $query->where(function ($query) {
             $query->where('start_time', '=', NULL);
             //to be planned
             $query->orWhere('start_time', '>=', new \DateTime());
             //planned
         });
     }])->get()->toArray());
     $content = $response->response->content();
     $content = json_decode($content, true);
     $content = collect($content);
     $content = $content->pluck('meetings')->collapse()->pluck('id')->toArray();
     $this->assertFalse(in_array($old->id, $content));
     $this->assertTrue(in_array($new->id, $content));
     $this->assertFalse(in_array($other->id, $content));
 }