Exemplo n.º 1
0
 public function boot()
 {
     if ($replace_patterns = config('services.bank_replace_patterns')) {
         Bin::saving(function (Bin $bin) use($replace_patterns) {
             foreach ($replace_patterns as $pattern => $replace) {
                 $bin->bank = preg_replace("/{$pattern}/", $replace, $bin->bank);
             }
         });
     }
 }
Exemplo n.º 2
0
 /**
  * @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();
 }