app/Http/Controllers/Admin/LocationController.php
private function childLocationStatus(int $parent_id): stdClass
    {
        $prefix = DB::connection()->getTablePrefix();

        $expression =
            $prefix . 'p0.pl_place IS NOT NULL AND ' . $prefix . 'p0.pl_lati IS NULL OR ' .
            $prefix . 'p1.pl_place IS NOT NULL AND ' . $prefix . 'p1.pl_lati IS NULL OR ' .
            $prefix . 'p2.pl_place IS NOT NULL AND ' . $prefix . 'p2.pl_lati IS NULL OR ' .
            $prefix . 'p3.pl_place IS NOT NULL AND ' . $prefix . 'p3.pl_lati IS NULL OR ' .
            $prefix . 'p4.pl_place IS NOT NULL AND ' . $prefix . 'p4.pl_lati IS NULL OR ' .
            $prefix . 'p5.pl_place IS NOT NULL AND ' . $prefix . 'p5.pl_lati IS NULL OR ' .
            $prefix . 'p6.pl_place IS NOT NULL AND ' . $prefix . 'p6.pl_lati IS NULL OR ' .
            $prefix . 'p7.pl_place IS NOT NULL AND ' . $prefix . 'p7.pl_lati IS NULL OR ' .
            $prefix . 'p8.pl_place IS NOT NULL AND ' . $prefix . 'p8.pl_lati IS NULL OR ' .
            $prefix . 'p9.pl_place IS NOT NULL AND ' . $prefix . 'p9.pl_lati IS NULL';

        return DB::table('placelocation AS p0')
            ->leftJoin('placelocation AS p1', 'p1.pl_parent_id', '=', 'p0.pl_id')
            ->leftJoin('placelocation AS p2', 'p2.pl_parent_id', '=', 'p1.pl_id')
            ->leftJoin('placelocation AS p3', 'p3.pl_parent_id', '=', 'p2.pl_id')
            ->leftJoin('placelocation AS p4', 'p4.pl_parent_id', '=', 'p3.pl_id')
            ->leftJoin('placelocation AS p5', 'p5.pl_parent_id', '=', 'p4.pl_id')
            ->leftJoin('placelocation AS p6', 'p6.pl_parent_id', '=', 'p5.pl_id')
            ->leftJoin('placelocation AS p7', 'p7.pl_parent_id', '=', 'p6.pl_id')
            ->leftJoin('placelocation AS p8', 'p8.pl_parent_id', '=', 'p7.pl_id')
            ->leftJoin('placelocation AS p9', 'p9.pl_parent_id', '=', 'p8.pl_id')
            ->where('p0.pl_parent_id', '=', $parent_id)
            ->select([DB::raw('COUNT(*) AS child_count'), DB::raw('SUM(' . $expression . ') AS no_coord')])
            ->first();
    }
private function childLocationStatus(int $parent_id): stdClass
    {
        $prefix = DB::connection()->getTablePrefix();

        $expression =
            $prefix . 'p0.pl_place IS NOT NULL AND ' . $prefix . 'p0.pl_lati IS NULL OR ' .
            $prefix . 'p1.pl_place IS NOT NULL AND ' . $prefix . 'p1.pl_lati IS NULL OR ' .
            $prefix . 'p2.pl_place IS NOT NULL AND ' . $prefix . 'p2.pl_lati IS NULL OR ' .
            $prefix . 'p3.pl_place IS NOT NULL AND ' . $prefix . 'p3.pl_lati IS NULL OR ' .
            $prefix . 'p4.pl_place IS NOT NULL AND ' . $prefix . 'p4.pl_lati IS NULL OR ' .
            $prefix . 'p5.pl_place IS NOT NULL AND ' . $prefix . 'p5.pl_lati IS NULL OR ' .
            $prefix . 'p6.pl_place IS NOT NULL AND ' . $prefix . 'p6.pl_lati IS NULL OR ' .
            $prefix . 'p7.pl_place IS NOT NULL AND ' . $prefix . 'p7.pl_lati IS NULL OR ' .
            $prefix . 'p8.pl_place IS NOT NULL AND ' . $prefix . 'p8.pl_lati IS NULL OR ' .
            $prefix . 'p9.pl_place IS NOT NULL AND ' . $prefix . 'p9.pl_lati IS NULL';

        return DB::table('placelocation AS p0')
            ->leftJoin('placelocation AS p1', 'p1.pl_parent_id', '=', 'p0.pl_id')
            ->leftJoin('placelocation AS p2', 'p2.pl_parent_id', '=', 'p1.pl_id')
            ->leftJoin('placelocation AS p3', 'p3.pl_parent_id', '=', 'p2.pl_id')
            ->leftJoin('placelocation AS p4', 'p4.pl_parent_id', '=', 'p3.pl_id')
            ->leftJoin('placelocation AS p5', 'p5.pl_parent_id', '=', 'p4.pl_id')
            ->leftJoin('placelocation AS p6', 'p6.pl_parent_id', '=', 'p5.pl_id')
            ->leftJoin('placelocation AS p7', 'p7.pl_parent_id', '=', 'p6.pl_id')
            ->leftJoin('placelocation AS p8', 'p8.pl_parent_id', '=', 'p7.pl_id')
            ->leftJoin('placelocation AS p9', 'p9.pl_parent_id', '=', 'p8.pl_id')
            ->where('p0.pl_parent_id', '=', $parent_id)
            ->select([DB::raw('COUNT(*) AS child_count'), DB::raw('SUM(' . $expression . ') AS no_coord')])
            ->first();
    }
private function childLocationStatus ( int $ parent_id ) : stdClass { $ prefix = DB :: connection ( ) -> getTablePrefix ( ) ; $ expression = $ prefix . 'p0.pl_place IS NOT NULL AND ' . $ prefix . 'p0.pl_lati IS NULL OR ' . $ prefix . 'p1.pl_place IS NOT NULL AND ' . $ prefix . 'p1.pl_lati IS NULL OR ' . $ prefix . 'p2.pl_place IS NOT NULL AND ' . $ prefix . 'p2.pl_lati IS NULL OR ' . $ prefix . 'p3.pl_place IS NOT NULL AND ' . $ prefix . 'p3.pl_lati IS NULL OR ' . $ prefix . 'p4.pl_place IS NOT NULL AND ' . $ prefix . 'p4.pl_lati IS NULL OR ' . $ prefix . 'p5.pl_place IS NOT NULL AND ' . $ prefix . 'p5.pl_lati IS NULL OR ' . $ prefix . 'p6.pl_place IS NOT NULL AND ' . $ prefix . 'p6.pl_lati IS NULL OR ' . $ prefix . 'p7.pl_place IS NOT NULL AND ' . $ prefix . 'p7.pl_lati IS NULL OR ' . $ prefix . 'p8.pl_place IS NOT NULL AND ' . $ prefix . 'p8.pl_lati IS NULL OR ' . $ prefix . 'p9.pl_place IS NOT NULL AND ' . $ prefix . 'p9.pl_lati IS NULL' ; return DB :: table ( 'placelocation AS p0' ) -> leftJoin ( 'placelocation AS p1' , 'p1.pl_parent_id' , '=' , 'p0.pl_id' ) -> leftJoin ( 'placelocation AS p2' , 'p2.pl_parent_id' , '=' , 'p1.pl_id' ) -> leftJoin ( 'placelocation AS p3' , 'p3.pl_parent_id' , '=' , 'p2.pl_id' ) -> leftJoin ( 'placelocation AS p4' , 'p4.pl_parent_id' , '=' , 'p3.pl_id' ) -> leftJoin ( 'placelocation AS p5' , 'p5.pl_parent_id' , '=' , 'p4.pl_id' ) -> leftJoin ( 'placelocation AS p6' , 'p6.pl_parent_id' , '=' , 'p5.pl_id' ) -> leftJoin ( 'placelocation AS p7' , 'p7.pl_parent_id' , '=' , 'p6.pl_id' ) -> leftJoin ( 'placelocation AS p8' , 'p8.pl_parent_id' , '=' , 'p7.pl_id' ) -> leftJoin ( 'placelocation AS p9' , 'p9.pl_parent_id' , '=' , 'p8.pl_id' ) -> where ( 'p0.pl_parent_id' , '=' , $ parent_id ) -> select ( [ DB :: raw ( 'COUNT(*) AS child_count' ) , DB :: raw ( 'SUM(' . $ expression . ') AS no_coord' ) ] ) -> first ( ) ; }
How many children does place have?  How many have co-ordinates?

@param int $parent_id

@return stdClass
How many children does place have? How many have co - ordinates?