This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

oliver9719
oliver9719

Hi Forum,

I recently started playing around with octobercms, also tried to develop some small pulgins. I have a problem where I am stuck at the moment, were great someone could gimme a hint maybe ?

I developed a small plugin, in the logic, I do

$this->ips = Ip::select('country_iso_code') ->whereRaw('INET_ATON("'.$IP.'")>= network_start_integer AND INET_ATON("'.$IP.'") <= network_last_integer') ->join('Country_Locations', 'Country_Locations.geoname_id', '=', 'blocks_ipv4.geoname_id') ->limit(1) ->get(); $this->page['countryInfo'] = $this->ips;

which returns

[{"country_iso_code":"DE"}]

which I can access by

            {{ countryInfo }}
            

in the layout (!).

But what I want to access, is only the DE to use it somewhere else in the code .. How do I get only this value ?

Any help were really cool !

Oliver

Last updated

oliver9719
oliver9719

My fault, maybe someone can profit from my own solution:

    $ips = Ip::select('*')
        ->whereRaw('INET_ATON("'.$IP.'")>= network_start_integer AND INET_ATON("'.$IP.'") <= network_last_integer')
        ->join('Country_Locations', 'Country_Locations.geoname_id', '=', 'blocks_ipv4.geoname_id')
        ->limit(1)
        ->first();
    $this->page['country'] = $ips->country_iso_code;

I changed the query from ->get(); to ->first(); and was then able to use the method thingy $ips->country_iso_code;

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.