src/repositories/DomainTariffRepository.php
public function getTariff()
    {
        if ($this->app->user->isGuest) {
            $seller = $this->app->user->seller;
            $client_id = null;
        } else {
            $seller = $this->app->user->identity->seller;
            $client_id = $this->app->user->id;
        }

        return $this->app->get('cache')->getOrSet([__METHOD__, $seller, $client_id], function () use ($seller, $client_id) {
            $res = Tariff::find()
                ->action('get-available-info')
                ->joinWith('resources')
                ->andFilterWhere(['type' => 'domain'])
                ->andFilterWhere(['seller' => $seller])
                ->andWhere(['with_resources' => true])
                ->all();

            if (is_array($res) && !empty($res)) {
                return reset($res);
            }

            return null;
        }, 3600);
    }
public function getTariff()
    {
        if ($this->app->user->isGuest) {
            $seller = $this->app->user->seller;
            $client_id = null;
        } else {
            $seller = $this->app->user->identity->seller;
            $client_id = $this->app->user->id;
        }

        return $this->app->get('cache')->getOrSet([__METHOD__, $seller, $client_id], function () use ($seller, $client_id) {
            $res = Tariff::find()
                ->action('get-available-info')
                ->joinWith('resources')
                ->andFilterWhere(['type' => 'domain'])
                ->andFilterWhere(['seller' => $seller])
                ->andWhere(['with_resources' => true])
                ->all();

            if (is_array($res) && !empty($res)) {
                return reset($res);
            }

            return null;
        }, 3600);
    }
public function getTariff ( ) { if ( $ this -> app -> user -> isGuest ) { $ seller = $ this -> app -> user -> seller ; $ client_id = null ; } else { $ seller = $ this -> app -> user -> identity -> seller ; $ client_id = $ this -> app -> user -> id ; } return $ this -> app -> get ( 'cache' ) -> getOrSet ( [ __METHOD__ , $ seller , $ client_id ] , function ( ) use ( $ seller , $ client_id ) { $ res = Tariff :: find ( ) -> action ( 'get-available-info' ) -> joinWith ( 'resources' ) -> andFilterWhere ( [ 'type' => 'domain' ] ) -> andFilterWhere ( [ 'seller' => $ seller ] ) -> andWhere ( [ 'with_resources' => true ] ) -> all ( ) ; if ( is_array ( $ res ) && ! empty ( $ res ) ) { return reset ( $ res ) ; } return null ; } , 3600 ) ; }
Returns the tariff for the domain operations
Caches the API request for 3600 seconds and depends on client id and seller login.
@return Tariff|null The domain tariff or boolean `false` when no tariff was found
Returns the tariff for the domain operations Caches the API request for 3600 seconds and depends on client id and seller login .