/** * @param $bin * @return mixed */ public function getJsonData($bin) { /** @var Bin $model */ $model = Bin::where('bin', $bin)->first(); if (!$model) { $model = Bin::create($this->httpGet($this->makeUrl('json', $bin))); } elseif ($model->invalidated()) { $model->setRawAttributes($this->httpGet($this->makeUrl('json', $bin)))->save(); } return $model->toApiView(); }