code = $code; $this->name = $name; } public static function all() { $clients = self::getClients(); return collect(array_map(function($client) { return new Client( $client['id'], $client['name']); }, $clients)); } public function toArray() { return [ 'code' => $this->code, 'name' => $this->name, ]; } }