id = $row->id; $this->name = $row->name; $this->html = Text::renderEmojis($row->html); $this->raw_html = $row->html; $this->enabled = $row->enabled; $this->type = $row->type; $this->custom_score = $row->custom_score; $this->order = $row->order; } /** * @return array */ public static function all(): array { $rows = DB::getInstance()->query('SELECT * FROM nl2_reactions ORDER BY `order`')->results(); $fields = []; foreach ($rows as $row) { $fields[$row->id] = new Reaction($row); } return $fields; } /** * @param string $value * @param string $column * @return array|Reaction */ public static function find(string $value, string $column = 'id') { $rows = DB::getInstance()->query("SELECT * FROM nl2_reactions WHERE `$column` = ? ORDER BY `order`", [$value]); if (!$rows->count()) { return []; } if ($rows->count() === 1) { return new Reaction($rows->first()); } $fields = []; foreach ($rows->results() as $row) { $fields[$row->id] = new Reaction($row); } return $fields; } }