'json', ]; public function langColumns() { return ['title', 'title_short', 'title_decl']; } public static function boot() { parent::boot(); self::creating(function ($model) { /** @var $model static */ $model->num = (int)$model->max('num') + 1; }); } /** * Check if currency keyword is unique * @param string $keyword * @param int $except currency id * @return bool */ public function keywordExists($keyword, $except = 0) { $query = $this->where('keyword', $keyword); if ($except) { $query->where('id', '!=', $except); } return (int)$query->count() > 0; } /** * Check if currency code is unique * @param string $code * @param int $except currency id * @return bool */ public function codeExists($code, $except = 0) { $query = $this->where('code', $code); if ($except) { $query->where('id', '!=', $except); } return (int)$query->count() > 0; } }