public function filterByDepartment($department)
    {
        $result = $this->filter(
            function ($key, $value) use ($department) {
                if ($value->getDepartment() == $department) {
                    return true;
                }
            }
        );

        if ($result && 1 === count($result)) {
            $results = $result->toArray();

            return array_shift($results);
        }

        return $result;
    }
public function filterByDepartment($department)
    {
        $result = $this->filter(
            function ($key, $value) use ($department) {
                if ($value->getDepartment() == $department) {
                    return true;
                }
            }
        );

        if ($result && 1 === count($result)) {
            $results = $result->toArray();

            return array_shift($results);
        }

        return $result;
    }
public function filterByDepartment ( $ department ) { $ result = $ this -> filter ( function ( $ key , $ value ) use ( $ department ) { if ( $ value -> getDepartment ( ) == $ department ) { return true ; } } ) ; if ( $ result && 1 === count ( $ result ) ) { $ results = $ result -> toArray ( ) ; return array_shift ( $ results ) ; } return $ result ; }
Filter by department

@param  string $department
@return $this
Filter by department