コード例 #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);
             }
         });
     }
 }
コード例 #2
0
ファイル: BinList.php プロジェクト: Nebo15/nebo15.binlist
 /**
  * @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();
 }