argument('siteid')); Config::set('site',$site); $so = ProviderOauth::where('name',$this->argument('provider'))->singleOrFail(); $uo = User::where('email',$this->argument('user'))->singleOrFail(); if (($x=$so->tokens->where('user_id',$uo->id))->count() !== 1) abort(500,sprintf('Unknown Tokens for [%s]',$uo->email)); $to = $x->pop(); // Current Products used by services $products = Product::select(['products.*']) ->distinct('products.id') ->join('services',['services.product_id'=>'products.id']) ->where('services.active',TRUE) ->get(); $api = $so->API($to,TRUE); // @todo Remove TRUE $acc = $api->getItems()->pluck('pid','FullyQualifiedName'); foreach ($products as $po) { if (! $po->accounting) $this->error(sprintf('Product [%d](%s) doesnt have accounting set',$po->id,$po->name)); elseif ($acc->has($po->accounting) === FALSE) $this->error(sprintf('Product [%d](%s) accounting [%s] doesnt exist?',$po->id,$po->name,$po->accounting)); else $this->info(sprintf('Product [%d](%s) set to accounting [%s]',$po->id,$po->name,$po->accounting)); } } }